kpg
kpg

Reputation: 7966

Getting error: Cannot find module 'errno' running node script

I've just installed a fresh copy of Ubuntu 15.10, node 4.2.2 and npm 2.14.7 (with nvm) on a new machine. I have installed webpack and webpack-dev-server globally and installed my project dependencies with npm i.

Now when I try to run my node server I get the following errors:

module.js:339
  throw err;
  ^

Error: Cannot find module 'errno'
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> (/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:7:14)
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)

Any suggestions please?

Upvotes: 0

Views: 1573

Answers (2)

kpg
kpg

Reputation: 7966

It seems that something had gone wrong with my npm install and my project dependencies were only partly installed. Just running npm install again didn't fix it. I did an npm cache clean, removed my node_modules directory and then ran npm install again. The problem was then resolved.

Upvotes: 0

Yoan Arnaudov
Yoan Arnaudov

Reputation: 4144

Node.js searches for modules in the ./node_modules/ directory in the path where the program is.

For example if you script is here /home/user/scripts/somescript.js you should have /home/user/scripts/node_modules/.

Just do npm install errno in here /home/user/scripts/.

Upvotes: 2

Related Questions