Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js - throw new Error("Cannot find module '" + request + "'");

Tags:

node.js

What does this mean?

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

When I install a package and I incude I get that error! Why?

I am usig express.

e.g.

npm install -g moment

m = require('moment');

like image 637
Tampa Avatar asked Mar 29 '26 16:03

Tampa


1 Answers

If you want to use it in a script, you have 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 moment without the -g flag and it will work.

like image 71
srquinn Avatar answered Apr 01 '26 09:04

srquinn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!