Node.js - reset a new error ("Cannot find module" + request + "");

What does it mean?

throw new Error("Cannot find module '" + request + "'");

When I install the package, and I say, I get this error! Why?

I am express.

eg.

npm install -g moment

m = require ('moment');

+3
source share
1 answer

If you want to use it in a script, you need to install it locally. If you want to use it in a shell, install it globally.

http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/

Basically, run npm install momentwithout a flag -gand it will work.

+4
source

All Articles