npm-cli.js not found on git-bash - node.js

I have recently installed nodejs and npm on windows. Everything is fine with it. However, for some reason npm does work in cmd, but gives the following error when called on git-bash.
module.js:327
throw err;
^
Error: Cannot find module 'B:\b\programma's\Nodejs\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:974:3
module.js:327
throw err;
^
Error: Cannot find module 'B:\b\programma's\Nodejs\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:974:3
I noticed that the path apears to be B:\b\, meaning that somewhere npm selects the drive twice.
I am aware of the fact that my question looks a lot like this question. I did check my windows PATH variable, and the nodejs folder(including npm folder) are in there.
I also saw this post, and the git-bash does not tell me that npm is not found
I hope someone can help me with this problem

Looks like one of your directories has a ' in it. I would back everything up, change that directory to something simple like prog without any punctuation, uninstall Node and git-bash, and very carefully follow the instructions reinstalling them.

Related

How to run Jest tests on WebStorm and WSL

I'm trying run Run/Debug configuration on WebStorm. I have configuration:
And when I run that configuration I got:
module.js:540
throw err;
^
Error: Cannot find module '/home/dtokarczyk/Develop/Company/e-home-react/\wsl$UbuntuhomedtokarczykDevelopCompanye-home-reactnode_modulesjestbinjest.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Process finished with exit code 1
I don't know how jest path I should add. Terminal tests work fine.
using WSL2 UNC paths is not supported. Some related tickets (https://youtrack.jetbrains.com/issue/WEB-43279, for example) are fixed in the next major update (2020.1), but general support is still not there. Please follow IDEA-197573 and WEB-39819 for updates

New to node.js found a possible PATH variable error

Fairly new to node.js and suddenly this error happened, I tried researching it and found out it could be PATH, but I tried adding it and could not find the solution.
C:\Windows\system32>node app.js --harmony
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'C:\Windows\system32\app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
I have no idea why your current working directory is C:\Windows\system32 but you really shouldn't be in there running Node code. That's for Windows specific system files only.
You'll need to change to the directory with app.js in it, or you'll need to specify the full path when running Node:
node C:\path\to\app.js --harmony
Like all command-line tools, the node program will look in the current directory unless told otherwise.

Why does VsCode NPM throw a module not found error?

Typically I have no issues at all but however the other day VsCode started throwing a error anytime I tried to use a nodejs command. For instance even NPM -V throws a error. I have attempted to delete the environmental variables and reapply them as well as restart and I even completely wiped nodejs from my system both under program files and appData and re installed it. If I goto a normal cmd windows prompt I get zero issues. However if I am inside of vscode I get the below error:
npm -v
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'E:\c\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'E:\c\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
This is just a simple version command in VScode. Thanks in advance for the help!
I was able to resolve this by pressing F1 in VsCode and selecting the cmd as the default terminal option. The guys at vscode actually helped me! https://github.com/Microsoft/vscode/issues/65893
Thanks! Hopefully this helps someone in the future :)
If selecting the simple CMD as the default terminal in VsCode does not fix this problem for some, try running VsCode as an administrator.

Cannot find module 'jspm'

Any ideas about the following errors?
C:\PGM\_CODE\zui>npm install -g jspm
C:\PGM\devel\node-v7.2.1-win-x64\jspm -> C:\PGM\devel\node-v7.2.1-win-x64\node_m
odules\jspm\jspm.js
C:\PGM\devel\node-v7.2.1-win-x64
`-- jspm#0.16.53
C:\PGM\_CODE\zui>gulp watch
Index generation: 83.257ms
module.js:472
throw err;
^
Error: Cannot find module 'jspm'
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> (C:\PGM\_CODE\zui\build\tasks\export-release.js:7:14)
Well, funny enough I had this problem in 2017 and ran into it again in 2019.
In 2019
So this time, in order to fix it: I removed the JS extension, and set a new node_modules path.
So in the command prompt I run:
SET NODE_PATH=D:\Users\bakopme\AppData\Roaming\npm\node_modules
And I changed the command to be:
const jspm = require('jspm');
Previously, in 2017
I had hardcoded the path to the JS file.
Obviously this isn't the right way to do it but I am mentioning it in case the other does not work.
const jspm = require('/PGM/devel/node-v7.2.1-win-x64/node_modules/jspm/jspm.js');

Node.js appends command to current working directory and throws an error

I just installed Node.js on my Windows 7 machine, added it to the PATH and tried to use it. npm works perfectly (at least for now) and node --version prints v4.1.2.
However, when I try to execute another command like node update it appends the command to the current working directory and, of course, fails :
$ node help
module.js:338
throw err;
^
Error: Cannot find module 'c:\path\to\working\directory\help'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:118:18)
at node.js:952:3
What can I do?

Resources