Note that there are some explanatory texts on larger screens.

plurals
  1. POnode.js, Error: Cannot find module 'express'
    primarykey
    data
    text
    <p>I am new to node.js, try to learn express to build my first web application. got stuck on my very first sample code. need some help to get it running. Before I post this question, I did search on stack overflow, found some similar questions but still could not fix it.</p> <blockquote> <p>Error: Cannot find module 'express'</p> </blockquote> <p>I am using mac os 10.8.2. I have node.js installed using nvm. </p> <blockquote> <p>node.js: 0.8.20 path to node: /Users/feelexit/nvm/v0.8.20/bin/node path to express: /Users/feelexit/nvm/node_modules/express</p> </blockquote> <p>here's my sample code: this file locates at:</p> <p><strong>/Users/feelexit/WebstormProjects/learnnode/node_modules/index.js</strong></p> <pre><code>var express = require('express'); var app = express(); app.get('/', function(req, res){ res.send('welcome to express'); }); app.listen(3000); </code></pre> <p>when I try to run this file "node index.js"</p> <p>I get following error message, please help me to fix it. thank you .</p> <pre><code>Error: Cannot find module 'express' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.&lt;anonymous&gt; (/Users/feelexit/WebstormProjects/learnnode/node_modules/index.js:1:81) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) feelexits-Mac:node_modules feelexit$ </code></pre> <p><strong>Update to answer chovy's question:</strong></p> <pre><code>feelexits-Mac:~ feelexit$ npm install npm ERR! install Couldn't read dependencies npm ERR! Error: ENOENT, open '/Users/feelexit/package.json' npm ERR! If you need help, you may report this log at: npm ERR! &lt;http://github.com/isaacs/npm/issues&gt; npm ERR! or email it to: npm ERR! &lt;npm-@googlegroups.com&gt; npm ERR! System Darwin 12.2.0 npm ERR! command "/Users/feelexit/nvm/v0.8.20/bin/node" "/Users/feelexit/nvm/v0.8.20/bin/npm" "install" npm ERR! cwd /Users/feelexit npm ERR! node -v v0.8.20 npm ERR! npm -v 1.2.11 npm ERR! path /Users/feelexit/package.json npm ERR! code ENOENT npm ERR! errno 34 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/feelexit/npm-debug.log npm ERR! not ok code 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload