I'm trying to import the web3 library in Node.js so that I can handle Ethereum smart contract events, however I can't get the import to work.

I'm running Babel on each file to convert to es5, and the import in Node's index.js file looks like this:

import Web3 from 'web3'; 

When I add that "import Web3 from 'web3'" statement I get a "scrypt" error:

var scryptNative = __webpack_require__(!(function 
webpackMissingModule() { var e = new Error("Cannot find module 
'./build/Release/scrypt'"); e.code = 'MODULE_NOT_FOUND'; throw e; } . 


Error: Cannot find module './build/Release/scrypt'
at webpackMissingModule 
at eval (webpack:///./node_modules/scrypt/index.js?:3:181)
at Object../node_modules/scrypt/index.js 

This is my version of web3: (However, I have tried other versions which also don't work)

"web3": "^1.0.0-beta.26"

I've searched around but I can't find any solution to the above error. Any help is greatly appreciated.

  • What's wrong with const Web3 = require("web3");? – goodvibration Apr 24 at 6:57
  • 1
    P.S.: Regardless of your question, I recommend that you remove the ^, and also upgrade to beta34, which is the most stable version which I'm aware of. – goodvibration Apr 24 at 6:59
  • Nothing is wrong with the older syntax, but I'm already running Babel on all of my files (I'm importing React scripts) and I'm using "Import" in other places, so I might as well keep things consistent. Ok, I'll upgrade web3. – Steve Apr 24 at 7:05
  • You'll actually be downgrading web3, since at present, the ^ brings you to beta52 or later. – goodvibration Apr 24 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.