2
Error: Cannot find module 'once'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/duplexify/node_modules/end-of-stream/index.js:1:74)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

I'm getting this error when I try running my server.js with nodemon. I looked in my node_modules folder and there is a 'once' folder in there. I tried

rm -rf node_modules
npm install

to remove the entire node_modules folder and reinstall but it didn't work. I also did

npm install --save once

and still didn't work.

This is package.json

{
  "name": "FullMean_Friends",
  "version": "0.0.1",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "body-parser": "latest",
    "express": "~4.2.0",
    "mongoose": "latest"
  }
}
Ben Wong
  • 691
  • 2
  • 19
  • 29
  • Is the module once used by your application or nodemon? – bluesman Nov 04 '15 at 19:13
  • Sounds like you are doing something wrong in your require because it should work. This works for me `npm install once && node -e "require('once')" ` Also you are missing in your dependencies which is incorrect if you need it in your application. – pllee Nov 04 '15 at 22:26
  • Does `/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/duplexify/node_modules/end-of-stream/node_modules/once` exist and have both `package.json` and `once.js`? (yes, that's all a single path and it should exist as per `end-of-stream`'s `package.json`) In any case the problem is in `/usr/local/lib/node_modules/nodemon/` and not wherever your application is. You could try `sudo npn install once` in that directory as last resort. – a sad dude Nov 05 '15 at 01:20
  • tried npm install once && node -e "require('once')" and sudo npm install once, no luck. I also added "once": "latest" in package.json in the dependencies, still no luck. – Ben Wong Nov 05 '15 at 04:07
  • I suspect it's something that has to do with my npm. None of my applications is running and it's showing Error: Cannot find module 'once'. – Ben Wong Nov 05 '15 at 04:16
  • 1
    Got it working with going to /usr/local/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/l‌​atest-version/node_modules/package-json/node_modules/got/node_modules/duplexify/n‌​ode_modules/end-of-stream and do a npm install. Something was missing, but works now. – Ben Wong Nov 05 '15 at 04:18

0 Answers0