Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'winston'

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.

like image 769
hba Avatar asked Oct 15 '13 16:10

hba


People also ask

What is Winston NPM?

Winston allows you to implement multiple logging transports, i.e., a log can be recorded to a file, console, or database. The Logger configuration below logs to a console and a file. We'll add a transport array to the log configuration object.

Why We Use Winston in node JS?

winston allows you to define a level property on each transport which specifies the maximum level of messages that a transport should log. For example, using the syslog levels you could log only error messages to the console and everything info and below to a file (which includes error messages):

What is Winston library?

winston is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each winston logger can have multiple transports (see: Transports) configured at different levels (see: Logging levels).


1 Answers

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
like image 166
Tom Grant Avatar answered Sep 24 '22 08:09

Tom Grant