4

When I am running npm run test (mocha), I am getting this message. Using following: npm install --save mocha ganache-cli [email protected] Please advice.

> [email protected] test C:\Smart
> mocha

Error: Cannot find module 'web3'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Smart\test\inbox.test.js:3:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at C:\Smart\node_modules\mocha\lib\mocha.js:253:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (C:\Smart\node_modules\mocha\lib\mocha.js:250:14)
    at Mocha.run (C:\Smart\node_modules\mocha\lib\mocha.js:577:10)
    at Object.<anonymous> (C:\Smart\node_modules\mocha\bin\_mocha:591:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `mocha`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
4
  • 1
    Not too familiar with mocha testing outside of truffle, but have you tried uninstalling and then npm install web3 ?
    – thefett
    Commented Apr 24, 2018 at 19:00
  • 1
    Absolutely.No matter what version of web3 I install, it still producing the same error.
    – monkrus
    Commented Apr 24, 2018 at 21:51
  • @SergeiStadnik Can you put the first lines of the failing test inbox.test.js? ie the lines where you to try to require 'web3'.
    – Ismael
    Commented Apr 25, 2018 at 1:55
  • 1
    I rewrote the application, it had some syntax errors.Now I am getting a different error: Error: Cannot find module 'ganache-cli'
    – monkrus
    Commented Apr 25, 2018 at 19:56

1 Answer 1

1

If you are on windows, open up your terminal as administrator and run the following command:

npm install --global --production windows-build-tools

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.