Running npm in cmd giving me errors, I just installed nodejs msi on windows - node.js

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.

Related

How to run node commands from vscode

I've installed node and npm. I'm able to run node apps from Windows cmd but when I try using the vscode terminal, it says node is not recognized as an internal or external command. Please help me fix this
In Windows, you need to set the node.js folder path into system variables or user variables.
open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables
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 a variable doesn't exist, create it.
Restart your IDE or computer.
It is useful to add also "npm" and "Git" paths as variable, separated by a semicolon.

node not recognized even if it's in PATH

I can't seem to get node & npm available globally.
-I installed it with the windows installer
-Made sure the path "C:\Program Files\nodejs\node.exe" is in my user path as well as in system path.
userpath: C:\Ruby22-x64\bin;"C:\Program Files\nodejs";"C:\Users\Robin V\AppData\Roaming\npm"
(tried it with and without quotes)
systempath:
...;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\;C:\Program Files\nodejs\;C:\Users\Robin V\AppData\Roaming\npm\
- Rebooted multiple times
- Ran cmd as administrator
"node" still returns the not recognized error
UPDATE:
i checked tHKEY_CURRENT_USER\Environment and made sure the "PATH" key type is REG_EXPAND_SZ
i negated all paths with a space with " quotes
i there are no space between teh semicolons and the paths
i execture cmd as administrator
Anything else i can try ?
Can you please try one more thing, move node path to the first entry in the list of PATH strings.
Thanks SnK
set the C:\Program Files\nodejs\bin directory in window's PATH environment variable
Try this one dude if you're using windows:
1.) Search environment variables at your start menu's search box.
2.) Click it then go to Environment Variables...
3.) Click PATH, click Edit
4.) Click New and try to copy and paste this: C:\Program Files\nodejs\node_modules\npm\bin
If you got an error. Do the number 4.) Click New, then browse the bin folder
Add it to the PATH environment variable (under System Properties -> Environment Variables). After this run cmd and echo %PATH% to make sure that the nodejs and npm paths appears correctly.
This is what I have in my echo %PATH% (which works fine) : .... ;C:\dev\tools\nodejs\;C:\Users\username\AppData\Roaming\npm; ...
Are you sure you've got the right path? Could it be in C:\Program Files (x86)\nodejs?

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 is not recognized as an internal or external command but is in PATH

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".

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”)

Resources