I can't get npm modules to work with require?

I see other questions but I can't really find an answer to make it work. So here is:

node 0.6.6 npm 1.1.15 win7 64bit

What I've done:

  • Installed node "C:\Program Files (x86)\nodejs"
  • Installed npm extracted to "C:\Program Files (x86)\nodejs"
  • run from cmd: npm install express; // installed successfully (also installed with -g, global)
  • created a folder named express in "C:\Users\Totty\node_modules" with some content
  • created my app:

    var app = require('express').createServer();

    app.get('/', function(req, res){ res.send('hello world'); });


  • run my app: node "D:\Totty\NodeJS\projects\express01"

  • got the error: Cannot find module 'express'

node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module 'express' at Function._resolveFilename (module.js:334:11) at Function._load (module.js:279:25) at Module.require (module.js:357:17) at require (module.js:368:17) at Object. (D:\Totty\NodeJS\projects\express01\main.js:2:11) at Module._compile (module.js:432:26) at Object..js (module.js:450:10) at Module.load (module.js:351:31) at Function._load (module.js:310:12) at Array.0 (module.js:470:10)

I think I have to "say" to my script/node to look into the "C:\Users\Totty\node_modules" folder but I don't know how...

thanks for your help!

Try installing it locally in your app folder:

cd D:\Totty\NodeJS\projects\express01
npm install express