jpganz18
jpganz18

Reputation: 5858

how can I enable jade on my application?

I am trying to follow this Post

My server.js is like this

var express = require('express'); 
var app = express();
var jade = require('jade');

and i get this error

module.js:340
    throw err;
          ^
Error: Cannot find module 'jade'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/var/www/server.js:3:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:497:10)

but when I do this

try {
jade = require('jade');
} catch (err) {
var jade = require('/usr/local/lib/node_modules/jade/bin/jade');
}

I can start the engine, but when I enter the site I see

Error: Cannot find module 'jade'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at new View (/var/www/node_modules/express/lib/view.js:43:49)
    at Function.app.render (/var/www/node_modules/express/lib/application.js:488:12)
    at ServerResponse.res.render (/var/www/node_modules/express/lib/response.js:798:7)
    at io.sockets.on.socket.on.socket.get.data.message (/var/www/server.js:18:7)
    at callbacks (/var/www/node_modules/express/lib/router/index.js:164:37)
    at param (/var/www/node_modules/express/lib/router/index.js:138:11)

I tried installing jade with nmp install -g jade and also npm install jade --global

But nothing... any idea what im doing wrong? Ive checked other posts here and at other sites but no result

--EDIT--

when I make npm install jade --global I get this at the end (before some http GET and http 304 that all looks fine, no warning or error)

/usr/local/bin/jade -> /usr/local/lib/node_modules/jade/bin/jade
[email protected] /usr/local/lib/node_modules/jade
âââ [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])

Upvotes: 0

Views: 2129

Answers (1)

Plato
Plato

Reputation: 11052

Perhaps the global install path for Node is not actually in your system path. The error in the second case is probably a subsidiary module like Express also trying to require jade.

Try a local install: assuming jade is in your package.json (it is by default, if you used the express command to generate a skeleton) run this in your project root:

npm install -d

this flag installs dependencies

Upvotes: 1

Related Questions