Can't run npm or any Node Module on Cmder (Windows 7) - node.js

I simply can't run "npm" or, for instance, "gulp" in my cmder. But I can run it if I manually open the cmd
λ gulp
'gulp' is not recognized as an internal or external command,
operable program or batch file.
If I run npm manually from the Nodejs directory, it works. So I added an alias with alias npm=C:\Progra~1\nodejs\npm.cmd $* and now npm works, but I guess that's not the best solution, since I can't run Node modules.
What I've tried
I've tried to add "%APPDATA%\npm\node_modules" and
"AppData\Roaming\npm" to both System and User environment variables
Restarting the computer
Running cmd as admin inside of Cmder
Add "%APPDATA%\npm\node_modules" and "AppData\Roaming\npm" to
"Cmder's user-startup.cmd" path.
I can run Ruby's gem or Python inside of cmder just fine, but Node just won't work specifically inside of Cmder (but will work on window's native cmd.exe)

Fixed
Download the lastest version of Cmder through the github repo https://github.com/cmderdev/ instead of downloading it from the website.

Add the "C:\Progra~1\nodejs\" to your user path in Windows using the System Properties window. Restart Cmder. Cmder can then see all the nodejs related executables, including npm.
The standard release from the website will work.
source: this has worked for me.

Run cmder as admin..
The reason why the workaround (moving files in the same directory) works is because running the cmder does not have privileges to access files outside of its directory. So either give it orivelages or Run as Admin. That it expands da the paths it can access and removes limitations/restrictions.
problem solved

For me what worked was using the cmder from selecting save file instead of open with Windows Explorer (default)

Briefly:
Create shortcuts for npm.cmd and npx.cmd and put them to ../cmder/bin/ folder.
Detailed:
Install nodejs. For example, to C:/Program Files/nodejs
Install cmder. For example, to C:/cmder
Go to nodejs folder and create shortcuts for npm.cmd and npx.cmd (right click - create shortcut). Windows will show message that cannot create here, will be created on Desktop instead - agree.
Copy shortcuts from Desktop to /cmder/bin/.
Rename them to npm.cmd and npx.cmd relatively (remove - Shortcut).
Reopen cmder, run npm.

Related

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.

Fixing npm path in Windows 8 and 10

Have done a lot of googling, tried reinstalling node.js using the official installer, but my npm pathing still doesn't work.
This doesn't work
npm install foo
I get an error message saying missing module npm-cli.js
2 hours of googling later I discovered a workaround
Instead of simply 'npm' I type
node C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
But how can I correct my nodejs install so I can simply type 'npm' ?
You need to Add C:\Program Files\nodejs to your PATH environment variable. To do this follow these steps:
Use the global Search Charm to search "Environment Variables"
Click "Edit system environment variables"
Click "Environment Variables" in the dialog.
In the "System Variables" box, search for Path and edit it to include C:\Program Files\nodejs. Make sure it is separated from any other paths by a ;.
You will have to restart any currently-opened command prompts before it will take effect.
get the path from npm:
npm config get prefix
and just as a future reference, this is the path I added in Windows 10:
C:\Users\{yourName}\AppData\Roaming\npm
Update:
If you want to add it for all users just add the following path [by #glenn-lawrence from the comments]:
%AppData%\npm
I have used the cmdlet and navigate to the path you want to switch your npm files to. Type in npm root -g to see what the current path your npm is installed to. Next use npm config set prefix and your npm path will be changed to whatever directory you are currently on.
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
You may also Visit this link for more info.
Go to control panel -> System -> Advanced System Settings then environment variables.
From here find the path variable, Go to the end of the line and paste "C:\Program Files\nodejs\node_modules\npm\bin" (change the path to the directory to where ever you installed it e.g. if you specifically installed it anywhere change it)
Edit the System environment variables, and enter following path:
C:\Program Files\nodejs\node.exe;
C:\Users\{yourName}\AppData\Roaming\npm
Installed Node Version Manager (NVM) for Windows: https://github.com/coreybutler/nvm-windows
I'm using Windows 10 - 64 bit so I run...
Commands:
nvm arch 64 (to make default the 64 bit executable)
nvm list (to list all available node versions)
nvm install 8.0.0 (to download node version 8.0.0 - you can pick any)
nvm use 8.0.0 (to use that specific version)
In my case I had to just switch to version 8.5.0 and then switch back again to 8.0.0 and it was fixed.
Apparently NVM sets the PATH variables whenever you do that switch.
You can follow the following steps:
Search environment variables from start menu's search box.
Click it then go to Environment Variables
Click PATH
click Edit
Click New and try to copy and paste your path for 'bin' folder [find where you installed the node] for example according to my machine 'C:\Program Files\nodejs\node_modules\npm\bin'
If you got any error. try the another step:
Click New, then browse for the 'bin' folder
If after installing your npm successfully, and you want to install VueJS then this is what you should do
after running the following command (as Admin)
npm install --global vue-cli
It will place the vue.cmd in the following directory
C:\Users\YourUserName\AppData\Roaming\npm
you will see this in your directory.
Now to use vue as a command in cmd. Open the cmd as admin and run the following command.
setx /M path "%path%;%appdata%\npm"
Now restart the cmd and run the vue again. It should work just fine, and then you can begin to develop with VueJS.
I hope this helps.
This worked for me:
1. npm root -g (to see the current npm is installed)
2. npm config set prefix (to change the path)
I did this in Windows 10,
Search for Environment Variables in the Windows search
"Edit the System environment variables" option will be popped in the result
Open that, select the "Path" and click on edit, then click "New" add your nodeJS Bin path i.e in my machine its installed in c:\programfiles\nodejs\node_modules\npm\bin
Once you added click "Ok" then close
Now you can write your command in prompt or powershell.
If you using WIndows 10, go for powershell its a rich UI
change the path for nodejs in environment varibale.
add Environment Path to
C:\Program Files\nodejs\node.exe;C:\Users[your username]\AppData\Roaming\npm
steps 1
in the user variable and system variable
C:\Program Files\nodejs
then check both node -v
and the npm -v
then try to update the the npm i -g npm
I've had this issue in 2 computers in my house using Windows 10 each.
The problem began when i had to change few Environmental variables for projects that I've been working on Visual studio 2017 etc.
After few months coming back to using node js and npm I had this issue again and non of the solutions above helped.
I saw Sean's comment on Yar's solution and i mixed both solutions:
1) at the environmental variables window i had one extra variable that held this value: %APPDATA%\npm. I deleted it and the problem dissapeared!
If you can't work with npm packages, you propably has bad config with npm install packages, you try this:
Run the following command in your terminal to revert back to the default registry
npm config set registry https://registry.npmjs.org/
https://docs.npmjs.com/misc/config#registry
When you're on Windows but running VS Code in Windows Subsystem for Linux like this
linux#user: /home$ code .
you actually want to install NodeJs on Linux with
linux#user: /home$ sudo apt install nodejs
Installing NodeJs on Windows, modifying PATH and restarting will get you no results.
If, like me, you have MSYS_NO_PATHCONV = 1 configured as a user variable for Git Bash, this issue will be triggered. To workaround, you can either remove this variable or use a different shell (PowerShell) for npm.
I did Node repair with the .msi file and everything worked well.
I may be a total noob but I had no clue I had to install npm-cli first. I had just assumed I already had it.
npm install --global vue-cli

Nodejs on Win7 - use npm only through Nodejs command prompt

I have a question about usage of Nodejs.
I installed it on Win7 and run (green Node.js icon) it, but when I tried to run "npm install" command it dodn't work. I had to move to Nodejs command prompt where npm is working.
Is that how it supposed to work?
Once you install NodeJS under Windows, it goes into the global PATH, meaning that it is available in the usual Windows command prompt. So, just open one by pressing:
Windows+R
Type cmd and press Enter
Then type node -v. You should be able to see an appropriate response.
Add your AppData\Roaming\npm and Program Files\nodejs folder to your path.
Also have a look at this:
Node.js doesn't recognize system path?
Second answer helped me to add my Roaming folder.

Grunt on Windows 8: 'grunt' is not recognized

I'm having a problem running Grunt from the command line on my Windows 8 machine.
My research indicates the most common solution is to install grunt-cli, since Grunt is no longer global. I also need to make sure I actually install the Grunt task runner, since that's not installed with grunt-cli.
Other solutions point to the PATH system environment variable, but that appears to be pointed as I'd expect to:
C:\Users[username]\AppData\Roaming\npm
Having done all that, I'm still getting a "'grunt' is not recognized as an internal or external command, operable program or batch file" error message in the CLI. I've tried the following things, uninstalling everything after every attempt:
Installed grunt-cli globally (npm install -g grunt-cli), then grunt at the directory level I want to use it (npm install grunt)
The same as above, but with the order of installation reversed
The same as both of the above, but using the Admin Command Prompt
Am I missing something obvious?
I've not had any issues with grunt on several different windows 8 machines.
If you open the folder: C:\Users\[username]\AppData\Roaming\npm
Do you have a file named grunt.cmd in this folder?
If not I'd maybe try npm install -g grunt-cli again, maybe from an elevated command prompt.
If this exists and you have C:\Users\[username]\AppData\Roaming\npm in your PATH environment variable then typing grunt from a command prompt should work.
Silly question, have you tried closing the command prompt and opening a new one?
Confirm your PATH is correct (and not messed up). Just type PATH from the command prompt. There's really no other explanation that makes sense given the error you're describing and the steps you've taken.
Normally, using the where grunt command would have found grunt.cmd in your path if npm is installed correctly and it has been properly added to the system path.
Close all Command Prompt instances.
Start a new Command Prompt instance.
Type PATH Enter and verify if C:\Users\Username\AppData\Roaming\npm is part of the path.
If not, you need to log off and on again,or close the Command Prompt and restart the explorer process.
In the Command Prompt, type where grunt Enter.
You're good if it reports:
C:\Users\Username\AppData\Roaming\npm\grunt
C:\Users\Username\AppData\Roaming\npm\grunt.cmd
Otherwise, you have to reinstall the grunt-cli package if it reports:
INFO: Could not find files for the given pattern(s).
Apparently, programs that change the PATH environment variable must broadcast a WM_SETTINGCHANGE message. The Windows' System settings window does it correctly when you change the PATH variable, but the NPM installer doesn't. That's why you have to restart explorer (or log off or restart, which has the same effect).
I know this has been answered but I thought I'd offer my step by step solution for windows 8.
First thing I checked was the PATH in my laptops Environment Variables (Right click my computer > properties > advanced system settings > Environment Variables)
It wasn't listed in there so I added a new variable in User variables (so it was specific only to my user account)
In the new user variable prompt I entered the following;
Variable Name: PATH
Variable Value: %USERPROFILE%\AppData\Roaming\npm
Quit command prompt, repoened, navigated to my projects directory and tried running grunt again and... SUCCESS!
I had the same issue.
I tried different things:
Restart computer
Deleted the grunt folder and ran
npm install -g grunt -cli
Didn't work.
Finally tried:
npm install -g grunt-cli
Worked perfectly.
Tried
where grunt
and I saw 2 locations where it was found.
I was facing the same problem on windows 8
I have added ' %APPDATA%\npm ' to the path variable . It has been working fine.
some times NPM install corrupts the basic windows path. i usually have a copy of my own version of PATH mainted separately. every week or on some installs i manually configure and update the %PATH% variable.
Basically Grunt.cmd is not availbe through %PATH% variable.
I have stucked with problem on Windows 8, that after install grunt-cli I've always got "command not found" while I'm tried to check grunt -v or where grunt. So I've added to enviroment PATH this path C:\Program Files (x86)\Git\local and run grunt.cmd from that folder (you need to look in node_modules folder here). And after reloading my terminal everything started to work.
Same happened to me and here was the solution:
Have you got 2 different versions of Node.JS installed?
Maybe Nodist?
This means you likely got NPM installed twice which will install the commands into 2 different folders:
Once into C:\Users\<user>\AppData\Roaming\npm and once into C:\dev\nodist\bin\bin.
C:\dev\nodist\bin\bin wasn't on my path variable so I added it, and I removed the Node.JS version I didn't want to use.
If you have no grunt.cmd file created by npm, make sure that you do not have a .npmrc in your home directory with: bin-links=false in it.
After getting a tonne of "'grunt' is not recognized as an internal or external command," errors, I solved this on Windows 10 by going to Path and adding C:\Users\Username\AppData\Roaming\npm

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