Cannot find module 'winston'
24,015
Solution 1
If the suggestion of setting the class path hasn't worked, it might likely be that you need to use an npm link. See: http://blog.nodejs.org/2011/04/06/npm-1-0-link/
For winston goto the root folder of your script and use the command:
npm link winston
Solution 2
You probably need to export NODE_PATH=/usr/local/lib/node_modules
, where /usr/local/lib/node_modules
is the path where your node modules are globally installed.
Related videos on Youtube
Author by
hba
Updated on January 11, 2022Comments
-
hba over 2 years
I wrote a little module that uses winston to log stuff.
I used
sudo npm install -g winston
(it is on a vm...so i'm not too concerned with sudo, etc.Log from npm:
[email protected] /usr/local/lib/node_modules/winston ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
When I try to run my module in node I get:
Error: Cannot find module 'winston' at Function.Module._resolveFilename (module.js:331:15) at Function.Module._load (module.js:273:25) at Module.require (module.js:357:17) at require (module.js:373:17) at Object.<anonymous> (/home/name/Code/neon/neon-js-spike/logger.js:2:9) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:349:32) at Function.Module._load (module.js:305:12) at Module.require (module.js:357:17)
System versions: ubuntu node -v = v0.11.7-pre npm -v = 1.3.8
P.S. I tried this on my home laptop (another ubuntu vm) and worked.
-
Amal Antony over 10 yearsYou could always install winston locally, in the same directory as your program.
-
-
Brett Pennings almost 9 yearsOn windows, but sure to Run as Administrator.
-
Mark about 7 yearsSame here, this worked for other modules, but not in this case