NPM node-v: COMMAND NOT FOUND - node.js

node -v
npm -v
live-server
Whenever i run these commands (there maybe others I don't know of) bash returns error. I use Bash as the default terminal of VS Code for my local dev environment. The strange thing is that when i try to run npm -v or node-v outside the integrated bash terminal of VS Code and directly into an independent Bash terminal it shows the result (the version). But the same wont work in the VSC integrated terminal and returns command not found. These strange things started happening just recently. Before that it was all fine.

Related

What could make my VScode terminal give different results than my Gitbash terminal?

I'm trying to check my Node.js install version and when I type node -v in Gitbash I get the version number back, but when I type it in VScode terminal running Gitbash I it says what I ran was not a command.
I don't know if this matters but all of the relevant programs are installed in the same location (C:\Program Files):

NPM run scripts aren't able to call `node`

Quick Summary
This is not a duplicate of the linked question, the issue there was a typo, this isn't isn't a typo.
I can run node in my bash terminal fine. If I try and run node inside an NPM script in that same bash terminal, then I get the error 'node' is not recognized as an internal or external command
Original Question
I'm having issues running npm install in one of my projects currently, but to be able to simplify all of the moving parts, I've created an NPM script in my package.json file, simply calling node nodetest.js.
The content of nodetest.js is as follows:
console.log('Node Test Success!');
On the command line, I can call node nodetest.js, and it will output the console log as expected.
If I call npm run nodetest, I get the error saying 'node' is not recognized as an internal or external command
Inside the same command line, I have access to node (/c/Program Files/nodejs/node), npm (/c/Program Files/nodejs/npm), and even npx (/c/Program Files/nodejs/npx)
Node is set in my PATH variable, and I've even added it to .bashrc.
What else could possibly be the problem?
Edit: I neglected to detail my system
Windows 10
Using Git Bash inside ConEmu
Node version 10.1.0
NPM version 6.0.0
Edit 2: Some further curiosities
If I change my NPM script to be "nodetest": "\"/c/Program Files/nodejs/node.exe\" nodetest.js", and then run npm run nodetest, I get an error in the output:
> "/c/Program Files/nodejs/node.exe" nodetest.js
The system cannot find the path specified.
BUT, if I copy that command exactly, and run it directly on the command line, it will work perfectly!

npm.cmd closes instantly after few seconds

I'm learning nodeJs. I managed to run nodejs commands on cmd and it works fine. Now I want to install express framework and for that in the tutorial I'm following it asks to type sudo install -g express on npm command prompt. So I typed npm in my windows search, and clicked on it. Right after few seconds less than 3 it closes straight away.
I found that npm.cmd exist in nodejs directory where node.exe found. What could be the problem here. If I were to type the above mentioned command in windows cmd, it says sudo is unrecognized program.SO must I use npm cmd?
After running cmd.exe , I guess you would have node installed but still run node -v , it should respond with the version meaning it's working.
Now if you want to explicitly install express.js you just have to run on, the command prompt itself,
npm install express -g.
Anyways you can follow this link from their official website. Hope it helps. Also sudo is a program for Unix like operating systems, just in case you needed it.

cannot run npm global modules on linux

Checkout the screenshot: Linux terminal
I have installed the global modules using npm but I am not able to use it. For example I run the command "stylus -v" and the terminal replies me with nothing. I am not able to understand why this problem might be happening as I am new to linux.

Node cli on Msysgit on WIndows 10

I recently decided to pick up Node on my personal laptop, which I upgraded to Windows 10, and the Node cli seems to hang when I try to run it.
Simply typing node on the console will not initiate the interface, and to do anything else I need to Ctrl+C out of it.
Additionally, running some npm commands take longer than they used to on my laptop. More noticeably, npm init seems to hang after confirming the information to be written to package.json.
Node version is 4.0.0
npm version is 2.14.2
Are there any known issues with Node and npm on Windows 10?
Edit:
After some troubleshooting, I've figured out the error only happens on Msysgit. Neither of the issues happen on the standard command prompt of Windows.
I had the same issue on Windows 7 with Node version 6.11.0 and Msysgit's MINGW64 terminal window.
The problem was caused by the an alias provided by Msysgit as demonstrated below:
$ alias node
alias node='winpty node.exe'
The solution is to run the command:
$ unalias node
Then node will run correctly.
You can add the unalias node command into your .bashrc file in your HOME directory to make this permanent.
Good luck!
Jeff

Resources