You are not logged in.

#1 2017-01-17 14:36:10

lviggiani
Member
Registered: 2014-02-28
Posts: 144

nodejs cannot find express anymore

After a recent upgrade of NPM and nodejs I tryed to run a node project that was working fine until then. Now I get this error:

Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/luca/Sources/birdcage-next/index.js:3:27)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

So I looked at the ArchWiKi and it says that npm installs modules under

/usr/lib/node_modules/npm/node_modules

and indeed express is not there.

So I ran

sudo npm install -g express

and I discovered that express has been installed in

/usr/lib/node_modules/

It looks like nodejs and npm does not point to the same folder. How can I fix that?

Offline

#2 2017-08-02 09:02:32

onecmc
Member
Registered: 2017-05-03
Posts: 13

Re: nodejs cannot find express anymore

+1

Yeah I've got the exact same problem.

Workaround:

echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.profile

More information:

https://stackoverflow.com/questions/134 … dules-path

Last edited by onecmc (2017-08-02 09:15:22)

Offline

Board footer

Powered by FluxBB