4
Geos-Mac:hone georgiana$ npm list
/Users/georgiana/local/hone
├─┬ express@2.3.6 
│ ├── connect@1.4.1 
│ ├── mime@1.2.2 
│ └── qs@0.1.0 
├── gently@0.9.0 
└── mysql@0.9.1

However, a simple script that contains

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

gives

Error: Cannot find module 'express'
at Function._resolveFilename (module.js:322:11)
.........

when trying to use express.

Please note that

Geos-Mac:hone georgiana$ npm express -v
1.0.6

and

Geos-Mac:hone georgiana$ node -v
v0.5.0-pre

Any ideas?

Georgiana
  • 323
  • 1
  • 4
  • 9
  • What do you see if you type: require.paths in node shell? – Geoff Chappell May 21 '11 at 11:48
  • `npm` installs modules locally. So your code needs to be near your `/.node_modules/` folder. – Raynos May 21 '11 at 11:49
  • The require_paths output `> require.paths [ '/Users/georgiana/.node_modules', '/Users/georgiana/.node_libraries', '/Users/georgiana/local/hone/lib/node' ]` `> Geos-Mac:node_modules georgiana$ pwd` `/Users/georgiana/local/hone/node_modules` `Geos-Mac:node_modules georgiana$ ls -lsa` `total 0` `0 drwxr-xr-x 5 georgiana staff 170 May 21 13:55 .` `0 drwxr-xr-x 7 georgiana staff 238 May 21 13:54 ..` `0 drwxr-xr-x 2 georgiana staff 68 May 21 13:55 .bin` `0 drwxr-xr-x 9 georgiana staff 306 May 21 01:01 gently` `0 drwxr-xr-x 13 georgiana staff 442 May 21 01:01 mysql` – Georgiana May 21 '11 at 12:28
  • 2
    solved by installing the express module inside the application's folder; inspired by the manual http://nodejs.org/docs/v0.4.1/api/modules.html#loading_from_node_modules_Folders so, inside `/Users/georgiana/Sites/nodejs-play` I executed the `npm install express` command, which installed the module in `/Users/georgiana/Sites/nodejs-play/node_modules/express` – Georgiana May 21 '11 at 12:51

1 Answers1

11

solved by installing the express module inside the application's folder; inspired by the manual http://nodejs.org/docs/v0.4.1/api/modules.html#loading_from_node_modules_Folders

so, inside /Users/georgiana/Sites/nodejs-play I executed the npm install express command, which installed the module in /Users/georgiana/Sites/nodejs-play/node_modules/express

Georgiana
  • 323
  • 1
  • 4
  • 9