I am trying to run simple express server in node. But when I install the dependencies it's giving me error that node "Cannot find express".
here is console logs
asus@DESKTOP-PL2TIDL MINGW64 /f/nitishWorkspace/nitishGitRepo/chatApp (master)
$ npm install -g express
express@4.14.0 C:\Users\asus\AppData\Roaming\npm\node_modules\express
├── array-flatten@1.1.1
├── escape-html@1.0.3
├── encodeurl@1.0.1
├── content-type@1.0.2
├── range-parser@1.2.0
├── fresh@0.3.0
├── path-to-regexp@0.1.7
├── cookie-signature@1.0.6
├── etag@1.7.0
├── content-disposition@0.5.1
├── vary@1.1.0
├── serve-static@1.11.1
├── methods@1.1.2
├── merge-descriptors@1.0.1
├── parseurl@1.3.1
├── cookie@0.3.1
├── utils-merge@1.0.0
├── depd@1.1.0
├── qs@6.2.0
├── on-finished@2.3.0 (ee-first@1.1.1)
├── finalhandler@0.5.0 (unpipe@1.0.0, statuses@1.3.0)
├── debug@2.2.0 (ms@0.7.1)
├── proxy-addr@1.1.2 (forwarded@0.1.0, ipaddr.js@1.1.1)
├── accepts@1.3.3 (negotiator@0.6.1, mime-types@2.1.11)
├── type-is@1.6.13 (media-typer@0.3.0, mime-types@2.1.11)
└── send@0.14.1 (destroy@1.0.4, statuses@1.3.0, ms@0.7.1, mime@1.3.4, http-errors@1.5.0)
asus@DESKTOP-PL2TIDL MINGW64 /f/nitishWorkspace/nitishGitRepo/chatApp (master)
$ node server.js
module.js:327
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (F:\nitishWorkspace\nitishGitRepo\chatApp\server.js:1:75)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
I think the problem lies in these lines
express@4.14.0 C:\Users\asus\AppData\Roaming\npm\node_modules\express
and
asus@DESKTOP-PL2TIDL MINGW64 /f/nitishWorkspace/nitishGitRepo/chatApp (master)
As you can notice the path is different here. I think that the dependencies are getting install in different directory and node is not able to access that. How can I solve this problem ?