Be the first user to complete this post

  • 0
Add to List

Error: can not find module 'underscore'

Issue

If your project dependency has changed on remote and they are not updated on your local machine, then when you try to pull the changes from the remote and try running the server you might get the error that it can not find certain modules.
module.js:338
    throw err;
          ^
Error: Cannot find module 'underscore'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/Kavit/nodl/server.js:1:71)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"

Soulution

*nix based system
sudo rm -rf node_modules/
sudo npm install
Windows based systems
npm install rimraf -g
rimraf node_modules
sudo npm install

References

https://docs.npmjs.com/cli/rm https://github.com/isaacs/rimraf



Also Read:

  1. Default function parameters
  2. How to publish a package on npm
  3. nodejs: generate uuid / guid
  4. imperative vs declarative/functional programming
  5. Understanding routers in express 4.0 - Visually
  6. Creating a simple event emitter using nodejs
  7. Generators and Yield in es6
  8. es6 iterators and iterables - creating custom iterators