Ganache-cli: Error: Cannot find module './build/Release/scrypt'

Created on 29 Jul 2016  ·  21Comments  ·  Source: trufflesuite/ganache-cli

I simply created a nodejs-file with the following content:

var Web3 = require('web3');
var web3 = new Web3();
var TestRPC = require('ethereumjs-testrpc');
web3.setProvider(TestRPC.provider());

testrpc version: 2.1.0
nodejs version: 6.2.2
gcc version : 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.1)
os : Linux Mint 18 Sarah

Expected Behavior

it should just do nothing but also not give errors.

Current Behavior

module.js:442
    throw err;
    ^
Error: Cannot find module './build/Release/scrypt'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/[myusername]/Desktop/testRPC/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/scrypt.js/node_modules/scrypt/index.js:3:20)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)

Possible Solution

It seems the problem comes with ethereumjs-wallet

Steps to Reproduce (for bugs)

  1. create the javascript-file with the shown content
  2. install web3, ethereumsjs-testrpc
  3. run the file with nodejs

Most helpful comment

My system is Mac OSX. The workaround I got is

  1. install "scrypt" manually ("sudo npm install -g scrypt")
  2. go to "ethereum-testrpc module folder"/node_modules/scrypt
  3. make a symbolic link to scrypt build folder e.g. "ln -s /usr/local/lib/node_modules/scrypt/build"

Hope this is helpful

All 21 comments

It looks like this is your issue. Give this a shot and reopen if it doesn't work. https://github.com/barrysteyn/node-scrypt/issues/108

Just to add, I tried the above, didn't work (maybe it helped)

I fixed it by adding --unsafe-perm when installing:

sudo npm install --unsafe-perm --verbose -g ethereumjs-testrpc

Because I got this error:

WARN EACCES user “root” does not have permission to access the dev dir

I actually just switched to nodejs v 6.2.2 and reinstalled all modules.
The problem came with v4.4.7 and with any other version because I installed it with the 4.x version.

Just thought I'd add to this as I came across the same problem.

Solution suggested by @tcoulter didn't seem to work for me.
Solution suggested by @BlockChange _worked_ for me.

I did not try @danielsun174 's solution.

Thanks everyone :+1:

Environment: node v4.5.0
Occur the same problem.
Follow @BlockChange --unsafe-perm work for me.
sudo npm install --unsafe-perm -g ethereumjs-testrpc

But what's the reason causes this problem?

Just to confirm that this issue went away for me switching from node 4.2.2 to 6.2.2

I meet it also,and I have used sudo npm install --unsafe-perm --verbose -g ethereumjs-testrpc.But nothing happen.Who can help me?

@woaiyaomai Which node version do you have?

My system is Mac OSX. The workaround I got is

  1. install "scrypt" manually ("sudo npm install -g scrypt")
  2. go to "ethereum-testrpc module folder"/node_modules/scrypt
  3. make a symbolic link to scrypt build folder e.g. "ln -s /usr/local/lib/node_modules/scrypt/build"

Hope this is helpful

thanks dendej, worked for me

Ubuntu: 16.04,
Node: 8.1.0,

I used to have the same issue when installing testrpc, what I did and actually worked were the following:

  1. install node version manager(nvm) ,
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
    then
    export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
    then test nvm installation:
    command -v nvm which should output nvm if successful.
    then what i did was using nvm long term support version (lts):
    nvm install --lts nvm use --lts
    Now, if you type node -v, bash should readv6.11.0
    (additionally, you could check your all node version you installed by using
    nvm ls
    and you could set long term support version as default using
    nvm alias defaults lts/*)
  1. navigate directory to node_modules using cd (location may various, depending on where you install node previously), there should be some folders like scrypt , nan etc.
    what i did was erase everything using sudo rm -rf /home/<myusername>/node_modules/*
    (be very careful about this step, It works for me, but please make sure you know what you are doing before deleting)

  2. Final step was reinstalling using the original:
    sudo npm install -g truffle ethereumjs-testrpc

And everything works like magic. Of course, you could test by typing testrpc and bash should give you 10 available accounts and their respective private keys. and typing 'truffle' and bash should give you a hint of list of available command.

This problem hunts me for two days. And finally with the help of my colleague and smart choice of a total re-installation and downgrade of node version, the problem has been finally solved.

Hopefully it helps! Cheers!

occured using __node v8.2.1__ after adding/installing an explicit dependency to web3 when ethereumjs-testrpc was already present and installed as a dependency.

throwing away node_modules and going for npm i afterwards fixed the issue.

I had this issue on windows 10 too. Fixed by installing Visual C++ 2015 Build Tools through Visual Studio, then deleting node_modules and npm i made the trick.

On Windows 7 x64, Node v8.9.3:

  1. delete node_modules folder
  2. start an elevated command prompt (run as administrator)
  3. install build tools: npm install --global --production windows-build-tools
  4. run npm install which will use the build tools to compile scrypt

NOTE: npm install must be run from the same elevated command prompt (compiling scrypt without admin rights will fail).

May be this was just with me:
I was using const ganache=require('ganache');

which was giving me this error
It is actually require('ganache-cli');

Silly mistake but it fixed

open /usr/local/lib/node_modules/remix-ide/node_modules/scrypt/index.js and change it to
require("./build/Release/scrypt")改为require("scrypt"), problem solved.

I had this issue with a fresh install of Ubuntu 19.04. The issue was caused by node-gyp failing higher up in the process as it needs python2.7 which is easily fixed:

sudo apt install python2.7
sudo ln -s /usr/bin/python2.7 /usr/bin/python

Restart your shell or source your .bashrc and the issue should be sorted.

change this line require("./build/Release/scrypt") to require("scrypt") from '/node_modules/scrypt/index.js'

@sudhiryadav can confirm this worked for me, thanks!

You can also run this and it should fix the issue:
sed -i -e 's/.\\/build\\/Release\\/scrypt/scrypt/' node_modules/scrypt/index.js

Was this page helpful?
0 / 5 - 0 ratings