Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node JS NPM modules installed but command not recognized

Tags:

node.js

npm

bower

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.

like image 484
Vishnu Sureshkumar Avatar asked Jun 08 '15 13:06

Vishnu Sureshkumar


People also ask

Why npm install command is not working?

On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

How do you fix npm is not recognized as an internal or external command?

Either delete the path from user variable or correct the right path (C:\Program Files\nodejs). Restart CMD and it should work.

Can't find node js command prompt?

Make sure the node path is added, if not added it. After doing this restart Visual Studio or open a fresh command prompt. From the command prompt type 'node -v' to echo the node version installed. You can also add the path to node or any other application directly on the command line.

How do I know if NPM is installed with NodeJS?

NPM is bundled together with NodeJS, so each time you install a specific version of NodeJS on your local computer, you will also have a specific version of NPM bundled with it. You can check the currently installed NPM version using the npm --version command:

What is NPM is not recognized error?

But sometimes, you may encounter the npm is not recognized error as shown below: > npm --version 'npm' is not recognized as an internal or external command, operable program or batch file. The error above happens when the Windows operating system doesn’t know what to do with the npm command.

How to resolve ‘node’ is not recognized as an internal error?

How to resolve ‘node’ is not recognized as an internal or external command error after installing Node.js ? There are many different ways to install node.js on a computer. The simplest method to verify whether node.js has been properly installed in your computer is simply type node-v in the command prompt or Windows PowerShell.

Why is node not recognized as a program?

'node' is not recognized as an internal or external command, operable program or batch file. This is the most common error and it is very simple to resolve this. It might be a case that the user might have properly installed node from the official node website. But sometimes, the reason is that the path variable is not defined in your system.


2 Answers

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.

like image 71
James Gentes Avatar answered Sep 19 '22 06:09

James Gentes


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

  1. Right-click My Computer
  2. Click on properties down the bottom
  3. Click on Advanced System Settings in the left bar
  4. 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

  1. Double click on PATH under 'user variables' section
  2. Add C:\Users\(your username)\AppData\Roaming\npm without the quotes

Global

  1. Double click on PATH under 'user variables' section
  2. 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

like image 23
julianpitt Avatar answered Sep 23 '22 06:09

julianpitt