Any idea how I can import a module who's name ends with .js?
example of module https://www.npmjs.com/package/bandchain2.js
import React, { useEffect, useState } from 'react';
import { Client } from '@bandprotocol/bandchain.js';
export default App = () =>{
return(
<div></div>
);
}
Failed to compile.
./src/components/app.js
Module not found: Can't resolve '@bandprotocol/bandchain.js' in '/mnt/g/Projects/test-app/src/components'
CodePudding user response:
I reproduced your problem with no compile issues and imported it as:
import { Client } from "bandchain2.js";
You're importing it as bandchain.js when the npmjs you provided is bandchain2.js
CodePudding user response:
import { Client } from "@bandprotocol/bandchain.js";
and you should add the following line to your package.json file.
"browser": { "crypto": false }
discussion of the relevant topic:https://github.com/brix/crypto-js/issues/291
CodePudding user response:
Resolved by using node v16. Seems that the problem only occurs with node 14 or the react/create-react-app version installed