node is not recognized as an internal or external command but is in PATH - node.js

Although I've follow suggestions from:
'node' is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova
Node.js doesn't recognize system path?
‘ant’ is not recognized as an internal or external command...
I'm having an strange issue: Resume, although node path is list in Path, it doesn't find node.
Workflow:
Microsoft Windows [Version 6.3.9600] //Running CMD on windows 8.1
(c) 2013 Microsoft Corporation. All rights reserved.
I followed suggestions in SO, adding variable to Environment Variables, and it's display Ok in Path:
C:\Users\myUser>path
PATH=c:\Program Files (x86)\nodejs ; (...omitted...) //So folder is there
Next line will fail
C:\Users\myUser>call jasmine-node spec
'node' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\myUser>cd "c:\Program Files (x86)\nodejs" //So I move to the folder list before...
But if I move to folder list in Path, then it works OK.
c:\Program Files (x86)\nodejs>call jasmine-node spec
> (...omitted...) //Exec OK.
c:\Program Files (x86)\nodejs>node
> //Exec OK. Waiting...
It seems contradictory.

The nodejs directory in your PATH isn't recognized because there's a space before the semicolon, so Windows is looking for a directory with a space at the end of the name, which doesn't exist.

Error: 'node' is not recognized as an internal or external command
The problem is may be the node is not installed on the machine in which the application is running.
Then install it and set the environment variable for nodejs.
Or
One more reason can be the nodejs path not set in the environment variable.
Check with the following -
open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> Path
the nodejs path should be available here.
If not available then add the following:
C:\Program Files (x86)\nodejs
OR
C:\Program Files\nodejs
Now Re-Run the application and the Error got resolved.

;C:\Program Files\nodejs\
Slash after \nodejs\ worked for me

Usually the environment variables are not effective till a system
Restart.
I suggest a System Restart for all those who face the same issue when doing a clean install.
This worked for me.

In Windows, you need to set node.js folder path into system variables or user variables.
1) open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables
2) in "User variables" or "System variables" find variable PATH and add node.js folder path as value. Usually it is C:\Program Files\nodejs;. If variable doesn't exists, create it.
3) Restart your IDE or computer.
It is useful add also "npm" and "Git" paths as variable, separated by semicolon.

If you did npm install jasmine-node -g you should just need to do jasmine-node spec (no call prefix).

If you've checked your PATH, and are sure that the path for node is added properly, then you're likely to face the problem while running node OR npm commands with CLI's other than the default command line interface of the operating system (e.g. Git bash in Windows).
The strange part is that you can check for node -v and npm -v in those CLIs, but for some reasons, they don't work well with those commands (especially when combined with install or update).
Possible Solution
Try running node with the default terminal for your OS.

I faced this issue even after adding node.exe to PATH. I wasn't able to run node command at random locations without running command prompt as administrator.
Solution to this issue is, you have to give full access permissions to this node.exe file for different user types. open the properties of node.exe, go to security tabs, check all the security options to the user on your local machine.
after doing this you should be able to access the node.exe file from any location.

things to check:
open CMD>Go to the directory where node.exe resides > type node -v > :
if it shows the version: Please add the same path (like>
PATH=C:\Programfiles\nodejs\;) in the OS path in environment variable (any of the
system or user variable, both work fine)
if it doesn't recognize, please add a variable PATHEXT=.exe; in the environment
variable (The PathExt is an Environment Variable that stores a list of the file
extensions for the operation system to execute) and save them.
Now open a new command prompt window and check.it must work.

After installing nodejs you have to restart your terminal or IDE .

C:\Program Files\nodejs
adding the path without the semi-colon did it for me...

For the issue which is coming "node' is not recognized as an internal or external command, operable program or batch file.", I have tried updating the path, but the issue didn't resolve. So I uninstalled and installed node.js and it worked for me.

The error:
node-is-not-recognized-as-an-internal-or-external-command
And the following solution:
Set Environment variable NODE_HOME as C:\Program Files\nodejs
Open cmd window and run:
cd "C:\Program Files\nodejs"
npm install connect
npm install -g appium

It's as simple as adding the location of nodejs (C:\Program Files (x86)\nodejs) to your PATH variable and restarting your application with "Run as administrator".

Related

Running npm in cmd giving me errors, I just installed nodejs msi on windows

I installed nodejs in Windows system from official website and npm giving errors:
CALL "C:\Program Files\node js\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not
recognized as an internal or external command, operable program or batch file.
I have given all sorts of paths. Please help me.
http://prntscr.com/gso39z
Add the following paths to your PATH environment variable
%USERPROFILE%\AppData\Roaming\npm
C:\Program Files\nodejs\
(note that i have windows 10, where your programs are installed can differ as per your windows version)
To permanently set PATH environment variable, follow these steps:
This PC/ My Computer Properties
Advanced System Settings, (right side)
from popup, click environment variable
select PATH environment variable under system variable, (not user variable) then click edit
Click new, and copy and paste one of the path (given) there.
new again and paste second path
to check if its set or not, goto terminal, and type PATH
note: if you type PATH, its value will be displayed, but if you type %PATH% , each of its value will act as a command input to terminal (windows terminal -_-).
Start the process by being an administrator.
Open up your command prompt as an administrator.
And if you are using older version of node say 6.9, please upgrade to 6.10, it may solve your problem.

Not able to use npm in WIndows

Error message in cmd.exe
Hi
I'm not able to use npm on Windows 8.1 64bit. It shows the error message as in image link. I have installed nodejs v5.7.1
ERROR MESSAGE:
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules
\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external com
mand,
operable program or batch file.
3.6.0
Tried changing PATH variables and installing a fresh copy in a different drive also
Please help.
Thanks
Download Cygwin
Launch Cygwin Terminal as Administrator, then run the following command
curl -L "https://npmjs.org/install.sh" | sh
This will do a fresh install of NPM. It could take a while to download but once the install completed if everything was successful, the last thing printed will be It Worked.
EDIT: Changed from npm-windows-upgrade to Cygwin
Go to your environment variables and on the system variables section remove the ComSpec variable
First delete this two folders
C:\Users\<your user name>\AppData\Roaming\npm
C:\Users\<your user name>\AppData\Roaming\npm cache
Then delete the Comspec system variable.
It works definitely on windows machine.
solution is very simple...open advance windows system settings
next....edit environment variable..in that...open system variable..in that...change comSpec value o C:\Windows\system32\cmd.exe...then press OK

Node JS NPM modules installed but command not recognized

Node JS and NPM were working well before. Recently I have re-installed the Node JS, NPM and the problem started. After I install a module like an example npm install -g bower, the module gets installed successfully but bower -v gives
'bower' is not recognized as an internal or external command,
operable program or batch file.
I have checked the installation path
C:\Users\XXXXX\AppData\Roaming\npm\node_modules has all the old installed modules. I have tried to uninstall them and reinstall the modules, but still, I am getting the same error.
Even I have deleted the entire folder and installed all the modules again but the result is the same.
I don't know why I am getting this error after reinstalling NodeJS NPM.
I had this same problem and fixed it by adding the 'npm' directory to my PATH:
Right-click 'My Computer' and go to 'Properties > Advanced System Settings > Environment Variables'.
Double click on PATH under the 'User variables for Username' section, and add C:\Users\username\AppData\Roaming\npm obviously replacing 'username' with yours. Based on the comments below, you may need to add it to the top/front of your path.
Restart your console window or IDE and you should get a response from the bower command.
I had the same problem as well but installed it globally so the other answers didn't work.
The nodeJS install may not have added npm to your PATH so it's not recognised globally.
Firstly: To figure out if you installed globally or for current user
If there is an npm folder at C:\Users\(your username)\AppData\Roaming\npm you've installed it for the current user
If there is an npm folder at C:\Program Files\nodejs\node_modules\npm or C:\Program Files(x86)\nodejs\node_modules\npm you've installed it globally for all users to access
Secondly: To add it to the Path
Right-click My Computer
Click on properties down the bottom
Click on Advanced System Settings in the left bar
Click on Environment Variables down the bottom
Now depending on whether you installed globally or for the current user will determine which PATH variable you are updating and with what path location
Local
Double click on PATH under 'user variables' section
Add C:\Users\(your username)\AppData\Roaming\npm without the quotes
Global
Double click on PATH under 'user variables' section
Add C:\Program Files\nodejs without the quotes (or with (x86))
Finally
Close all terminals or programs that aren't able to find npm and open them up again
Run npm config get prefix and check the correct npm path first and append the output to the PATH using command or adding manually.
npm config get prefix
C:\mydev\tools\npm\npm
set PATH=%PATH%;C:\mydev\tools\npm\npm
If the package is successfully installed and still shows the message "'npm' is not recognized as an internal or external command, operable program or batch file."
Click windows start button.
Look for "ALL APPS", you will see Node.js and Node.js Command prompt there.
You can run the Node.js Command prompt as administrator and soon as its run it will show the message "Your environment has been set up for using Node.js 6.3.0 (x64) and npm."
You should probably check if your node/bin directory is in your PATH variable. Look for it where you've been installing these global modules.
I'm not on windows, so I can't tell you the exact command, but you can check these variables navigating to [Control Panel -> System -> Advanced -> Environment Variables] or something like this.
I had the same issue in Windows
Two solution worked for me
If you are using bash shell, use npm run
Example : $ npm run ng --version
Use Windows power shell or command prompt
In my case the npm folder was already in the PATH variable.
If after trying everything else, you also still can't make it work, try to delete the folder from the PATH variable and put it at the beginning of the list.

Running node.js code just displays a node identifier

I have the following code in a file called server.js.
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
I use the command prompt and naviage to the folder where the file recides and then the run the command
node server.js
But I don't get the expected output. Instead I get
The node identifier for {My Machine Name} is v2hrfnqaj.
Note: I already have node installed in my machine and it was working fine.
Was getting this when I was trying to run cordova commands. Steps to resolve:
Windows
In CMD prompt, type "where node". As Michael mentioned, this shows
you the likely culprit, that you have 2 nodejs EXEs installed on
your machine.
Navigate to Start > Computer > Right-click Properties > Advanced system settings
Under the Advanced tab, select Environment Variables
Under System variables, select "Path" variable
Find nodejs EXE, usually "C:\Program Files (x86)\nodejs\"
Cut and paste this to the beginning of the "Path" variable. Ensure
the paths are separated by a ";"
Open a new CMD prompt and try cordova again
This happens when Harvest SCM is installed on your system. It has an executable with the name node.exe at <Program Files (x86)>\CA\SharedComponents\PEC\bin (where <Program Files (x86)> is your x86 program files folder). This path is present in your PATH variable before the path to Node.js's node.exe.
Update: You don't need the elaborate scheme listed in the old answer. You just have to open the Command Prompt and run:
C:\> nodevars
nodevars.bat is a small script that does essentially the same thing described below (but in a safer way). If you have node installed, this script should be in path. (If not make sure to add C:\Program Files\nodejs to your path. But make sure to append it in the end so Harvest SCM does not break).
Everything below is outdated, but I will leave it for the curious reader.
You can do either of following two things you can do to overcome this problem:
Remove <Program Files (x86)>\CA\SharedComponents\PEC\bin from PATH environment variable.
Add/move <Program Files (x86)>\nodejs to the beginning of the PATH environment variable (This is the currently accepted answer from djrpascu).
You can do better!
There are two problems with the above approaches:
You break Harvest SCM's functionality.
If you do not have elevated privileges to change PATH, you are out of options. (Thanks #Glats)
So I created this little batch file, and put it in a directory where I have several other personal scripts (this directory is in my PATH). Here's the gist for the script.
nodecmd.bat
#echo off
set path=%path:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;C:\Program Files (x86)\nodejs;
start %ComSpec%
Then the next time you want to run Node.js, instead of Command Prompt, you open the new script with "Run..." command.
Windows+R
nodecmd
A command prompt will appear. You can use this command prompt to run node without a hassle.
Explanation
This bit deletes the Harvest's executable's path from PATH variable:
%path:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;
And this adds the Node.js's path:
set path=...;C:\Program Files (x86)\nodejs;
The result is a string that contains the original PATH variable minus Harvest's path, plus Node's path. And it is set as PATH variable in the scope of current batch file.
Note: You might have to change the path's in the script to suit software installation folders in your system).
Next line, start %ComSpec% starts a Command Prompt. By this time, the PATH variabe is modified. With modified environment variables, you can run node within this new Command Prompt. The environment variable modification does not affect the rest of the system, making sure that Harvest SCM software runs without breaking.
Don't break your Harvest SCM by removing it from path. Try this one, open your windows command line (cmd) and then pass the following nodejs batch file so that it will set your command line to nodejs environment. Enjoy the node commands there.
C:> "C:\Program Files\nodejs\nodevars.bat"
You can also prioritize in the environments.
Steps:
Computer -> Right click -> Properties -> Advanced system settings -> Environment variables -> PATH(in system variables list) -> Edit -> Prioritize by moving up
This is old, but I ran into this same problem. Exact same message (with my machine name of course). The issue was that there was another node executable on the path, in C:\Program Files (x86)\CA\SharedComponents\PEC\bin. I'm on a windows machine, so running where node showed the two conflicting "node" executables in the path.
To fix the problem, I just removed the CA directory from the PATH environment variable.
I faced the same problem and simply changed the the name of node.exe file from Harvest. This hasn't broken anything from Harvest and I can keep working with it.
Change the Harvest's command name to node_.exe:
ren "C:\Program Files (x86)\CA\SharedComponents\PEC\bin\node.exe" "C:\Program Files (x86)\CA\SharedComponents\PEC\bin\node_.exe"
I think you're running the wrong node command.
Try locating or re-downloading your nodejs installation and add it to your path as the first directory. If you're running linux or unix you can try 'which node' to see what is being run.
Note that in some cases, the node.js executable is called nodejs so you may want to try
nodejs server.js as well
I used the node.js command prompt, instead of the windows default command prompt and it worked for me. Did not know why it did't work in the windows default command prompt.
I was also running with same issue - while defining the path for windows use below parameter
Windows:
set NODE_PATH=C:\nodejs
OR
Set the environment variable for nodejs
NODE_PATH=C:\nodejs
Path= C:\nodejs
(append the path contain this string “c:\nodejs”)

Node.JS - How to Run Node Command from any path?

I have installed the latest node.js from here . I see the %Path% variables have been set for Node.js. But, When i run node from C:\ , i get a "Node is not an recognized comman". But node command is working fine from "C:\Program Files (x86)\nodejs" path. Can i not run Node commands from C:\ or Say from an other path if i set the Env variables right? Please help. I am running a Win7 X64.
Thank You,
Faraaz
I had the exact same problem, but in my PATH variable I had: C:\Program Files\nodejs\.
After changing it to C:\Program Files\nodejs I could access it from anywhere.
What happens if you run node --version? I have never tried node.js from windows but if that doesn't work there is something wrong with your paths.
What do you get when you run echo %PATH%?
You should check if the path C:\Program Files (x86)\nodejs is present in your %PATH. If not, add it via the system properties (persistent change). In any case, restart your command prompt, it'll reload the %PATH variable. If you're lucky, it should work now :)
Most likely it happens because there is no Node path in your PATH environment variable.
I see two ways to solve this
Just add Node path into the end of PATH.
Reinstall Node as administrator
run 7-zip (or some file manager) with administrator privileges >>
browse to node-installer.msi >> open it, install node >> enjoy
My Sublime was working with Nodejs fine. I could press Alt-R and see the output from Node in Sublime. Then at some point I upgraded Sublime. I now have version 2.02 build 2221
And at some later point I tried Alt-R and got this infamous message
'node' is not recognized as an internal or external command
But it had worked, so what changed?
The steps I took to fix it were to install git bash and then
$ git clone https://github.com/tanepiper/SublimeText-Nodejs.git
$ cd SublimeText-Nodejs/
$ git checkout 095ba03344
Back in Sublime I clicked Preferences > Browse Packages. This opened up Windows Explorer with the folder:
C:\Users\me\AppData\Roaming\Sublime Text 2\Packages
I replaced the contents of the Nodejs folder with the git version. Re-started Sublime and then Alt-R sprang back into life.
Other things that turned out to be irrelevant were changing the file Nodejs.sublime-settings and tampering with system environment variables. The only thing that worked was 095ba03344 as described here
https://github.com/tanepiper/SublimeText-Nodejs/pull/39

Resources