Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node cannot find express module?

I am unaware what is causing this problem, because I thought it should be working. I do have expressed installed, at least according to npm:

C:\Users\phucker\Desktop>node init.js

module.js:340
    throw err;
          ^
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:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Users\phucker\Desktop\init.js:1:77)
    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 Function.Module.runMain (module.js:497:10)

C:\Users\phucker\Desktop>npm express -v
1.3.2

C:\Users\phucker\Desktop>

the code contained in init.js is

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

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

app.listen(3000);
like image 312
I'm Poor Avatar asked Dec 11 '22 13:12

I'm Poor


1 Answers

You need to have express installed locally in your node_modules folder. Check your node_modules and install it again if it is not there

like image 132
Akshat Jiwan Sharma Avatar answered Dec 30 '22 16:12

Akshat Jiwan Sharma