Node.js not searching modules in node_modules folder - node.js

I have installed packages using npm install -g http-server.
However, when i try to run this using node http-server. it throws error as below:
module.js:338
throw err;
^
Error: Cannot find module '/home/khagesh/http-server'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
I have tried setting NODE_PATH to /home/khagesh/npm/lib/node_modules.
As far as i can think is that node is not searching modules in node_modules and directly searching in user directory.
I am running it on Ubuntu 14.04.
Any help to fix this issue is appreciated.

Related

Npm can no longer be found in node_modules folder

I installed nvm for windows (https://github.com/coreybutler/nvm-windows) and switched to an older node version (v8.17.0). Since doing this, npm no longer works and returns:
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
module.js:550
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
I checked, and indeed although the folder C:\Program Files\nodejs\node_modules\ exists, it is completely empty. So npm indeed doesn't exist in that folder. where npmreturns:
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\MyName\AppData\Roaming\npm\npm
C:\Users\MyName\AppData\Roaming\npm\npm.cmd
Here I read to run SET PATH=C:\Program Files\Nodejs;%PATH%, which I did, but that made no difference (still the same error when running npm).
I've also tried re-installing npm using the steps here, but after re-installing it, it still gives the above error.
How can I solve this?

Node.js module.js:472 throw err;

I just started with Nodejs and right at the beginning I have a problem when I try to run some basic code in terminal. I installed Nodejs and npm using homebrew and when I try to run
node filename.js
I get this error:
`module.js:472
throw err;
^
Error: Cannot find module '/Users/TanjaIvan/global.js'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3`
I already tried uninstalling Nodejs and reinstalling it but no help. Current version of Nodejs is v7.10.0 and npm is 4.2.0.
Can someone help me with this error so I can continue with my tutorial?
Thank you

NPM module.js:472

When I try to start any npm command, the terminal displays
module.js:472
throw err;
^
Error: Cannot find module '/usr/lib/node_modules/npm/bin/node_modules/npm/bin/npm-cli.js'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:425:7)
at startup (bootstrap_node.js:146:9)
at bootstrap_node.js:540:3
I tried to reinstall node.js and npm.
How and where can I change the directory "usr/lib/node_modules/npm/bin/node_modules/npm/bin/npm-cli.js" to "usr/bin/node_modules/npm/bin/npm-cli.js".
p.s. When I copy all node_modules and past to /node_modules/npm/bin/, it works, but this is not an acceptable solution.
In you project folder there is a file named webpack.local.settings.js.sample. Rename the file to webpack.local.settings.js It worked for me.

npm install -g cordova, npm install -g ionic on Windows10

I was trying to do push notifications using angular and ionic, i was getting few issues while i was running Command prompt.
So i had to uninstall node.js and i tried to re-install the node.js , it installed successfully as i verified by node -v then it showed me v4.4.2
Then i tried to install cordova, ionic by using following commands:
npm install -g cordova
npm install -g ionic
it throwed following errors:
module.js:327
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
module.js:327
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Can someone help me how to resolve this issue, as i tried multiple times and restarted my pc.cordova issue
Please check the attached image for the reference and let me know what changes / how to resolve this issue

Windows -installed node.js but npm not found

I thought npm is automatically installed with the latest node.js installer on Windows. However when I try and use npm in the command console I get the following error
C:npm install socketio
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\foo\node_modules\npm\bin\n
pm-cli.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
I checked and npm DOES exist in the nodejs Program Files directory. So is this a PATH environment issue? And if so, how do I resolve so I can use npm anywhere I open a command console window?
What version of the windows are you trying?
And also you need to check the dependencies are installed for more information check the link,
https://www.npmjs.org/package/socket.io

Resources