Reputation: 11523
I'm kind of new to Node. So, I installed Web3 like this:
npm install -g web3
Success. Then I run node and try to require web3. It doesn't work:
Welcome to Node.js v12.11.0.
Type ".help" for more information.
> Web3 = require('web3')
Thrown:
Error: Cannot find module 'web3'
Require stack:
- <repl>
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:780:15)
at Function.Module._load (internal/modules/cjs/loader.js:685:27)
at Module.require (internal/modules/cjs/loader.js:838:19)
at require (internal/modules/cjs/helpers.js:74:18) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '<repl>' ]
}
Any ideas, I'm probably missing something obvious.
Upvotes: 2
Views: 1082
Reputation: 847
It looks like the web3 has problems when you globally install it using -g
.
I suggest you give npm init
to your project if you have not already given it and install it only for your project running:
npm install web3
inside of your project folder.
Upvotes: 3