-bash: node: command not found [duplicate] - node.js

I'm learning laravel and follwing this tutorial,
But when I went try and install npm, is says bash: npm: command not found

If you have already installed nodejs and still getting this error. npm: command not found..
run this
apt-get install -y npm

I also come here for the same problem, The solution I found is to install npm and then restart the Visual Studio Code

in redhat base OS (tested in centos 7)
yum install nodejs npm -y
in debian base OS
apt-get install -y npm

I am following the same tuturial and I had this issue and how I solved is just download the
8.11.4 LTS version
from this link then install it then the command worked just fine!

I know it's an old question. But it keeps showing in google first position and all it says it's "install node.js".
For a newbie this is not obvious, so all you have to do is go to the node.js website and search for the command for your linux distribution version or any other operating system. Here is the link:
https://nodejs.org/en/download/package-manager/
In this page you have to choose your operating system and you'll find your command. Then you just log into your console as a root (using putty for instance) and execute that command.
After that, you log as normal user and go again inside your laravel application folder and run again npm install command, and it should work.
Hope it helps.

The solution is simple.
After installing Node, you should restart your VScode and run npm install command.

If you already installed npm globally on your system, and you are still getting the above error message by using VSCode terminal. Just close your VSCode application and reopen again, that should resolve the issue.

First You need to check the node version using terminal (not gitbash)
node --version
npm --version
if those exists, Restart your pc and check
Cheers !!

In my case it was entirely my fault (as usual) I was changing the system path under the environment variables, in Windows, and messed up the path for Node/NPM. So the solution is to either re-add the path for NPM, see this answer
or the lazy option: re-install it which will re-add it for you.

Related

Npm error cannot find module

While running npm command I get the error
Error: Cannot find module 'C:\Windows\System32\node_modules\npm\bin\npm-cli.js'.
I tried uninstalling and installing nodejs but with no luck. Also I tried configuring the env vars
I'm not entirely sure about this, but I dont remember having nodejs/npm installed in Windows directory. It should be in your Appdata somewhere. Your install Paths maybe somehow corrupted
But here is a possible solution:
Go here:
Install it and run the following commands:
nvm list
nvm install [version]
for example:
nvm install v10.15.3
The Command should automatically select the installed version as default.
For further information check their Github Readme.
If they don't work right off, be sure to restart the Version Manager OR be sure to follow the instructions led out by the Github Readme.
Version Manager have one big benefit: The Community keeps them updated and because they use different Path architectures they can be installed at places where they weren't originally meant to be from the original installer which lead to a whole different outcome for you because they probably will not install directly into System32.
Other Node Version Manager you could check out (should all be Windows):
https://github.com/hakobera/nvmw
https://github.com/nullivex/nodist
Hope it helps!

npm-cli.js not found with the CLI command (in Windows 8.1 OS) npm -v

I am trying to install nodejs and npm in my computer with Windows 8.1 - 64 bit. I downloaded the msi from the official nodejs web site and installed it. When I tried to check the version of node by typing node -v, it worked perfectly. But when I tried to check whether npm is installed properly by typing npm -v, the following error appears.
How to fix this.Can someone help me in this. I referred the answers of similar questions here. And this also.But it did not worked too.
This is could because of incorrect installation. Have you tried reinstallation of Node and NPM? If not, uninstall from Program and Features and follow this walkthrough.
Also, need to set npm as global variable $PATH.

bash: npm: command not found?

I'm learning laravel and follwing this tutorial,
But when I went try and install npm, is says bash: npm: command not found
If you have already installed nodejs and still getting this error. npm: command not found..
run this
apt-get install -y npm
I also come here for the same problem, The solution I found is to install npm and then restart the Visual Studio Code
in redhat base OS (tested in centos 7)
yum install nodejs npm -y
in debian base OS
apt-get install -y npm
I am following the same tuturial and I had this issue and how I solved is just download the
8.11.4 LTS version
from this link then install it then the command worked just fine!
I know it's an old question. But it keeps showing in google first position and all it says it's "install node.js".
For a newbie this is not obvious, so all you have to do is go to the node.js website and search for the command for your linux distribution version or any other operating system. Here is the link:
https://nodejs.org/en/download/package-manager/
In this page you have to choose your operating system and you'll find your command. Then you just log into your console as a root (using putty for instance) and execute that command.
After that, you log as normal user and go again inside your laravel application folder and run again npm install command, and it should work.
Hope it helps.
The solution is simple.
After installing Node, you should restart your VScode and run npm install command.
If you already installed npm globally on your system, and you are still getting the above error message by using VSCode terminal. Just close your VSCode application and reopen again, that should resolve the issue.
First You need to check the node version using terminal (not gitbash)
node --version
npm --version
if those exists, Restart your pc and check
Cheers !!
In my case it was entirely my fault (as usual) I was changing the system path under the environment variables, in Windows, and messed up the path for Node/NPM. So the solution is to either re-add the path for NPM, see this answer
or the lazy option: re-install it which will re-add it for you.

NPM Command Not Found After Installing Node

I am having a very hard time getting the npm command to work, and unfortunately my knowledge of unix isn't good enough to solve this on my own. All I've done is brew install node, and I get the following errors:
When I type npm I get zsh: command not found: npm
Looking into this issue more I found this stack overflow answer:
Command not found after npm install in zsh
Following its advice I tried adding export PATH=/usr/local/share/npm/bin:$PATH to my .zshrc file. Still get the same error when typing npm
I can confirm it is in the path echo $PATH yields /Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/Users/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
I can also confirm that node has been installed node -v yields v0.12.2
Any ideas? I'm stumped
Not an answer, but maybe a solution...
Uninstall Node via brew: brew uninstall node
Then download Node from https://nodejs.org/en/download/ and install.
npm should then "just work".
I came across to this thread with the same problem but finally below is what worked for me which is without sudo
$ brew update
$ brew uninstall node
$ brew install node
$ chown -R YourUserName /usr/local/lib/node_modules/
$ brew postinstall node #This what the important step
Ok this is what worked for me:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node #This what the important step
In case this never got solved, this is what worked for me:
brew uninstall node
brew install node
brew doctor and see what needs to be pruned. My problem was there was a non-brew place where I had changed my install location for npm packages because I was trying to get an npm package to install for me. That was a mistake (having forgotten I initially installed node and npm through brew but now brew could no longer reach the npm install directory nor could it change or delete it). So brew prune didn't work even though the symlinks were supposedly deleted but it reminded me that I had changed the npm install location. And that brings us to:
Delete those directories
brew postinstall node
Hope it helps.
I found this article helpful with step-by-step details:
https://www.dyclassroom.com/howto-mac/how-to-install-nodejs-and-npm-on-mac-using-homebrew
Additionally, after all the steps in above article, node was working but my machine was still giving "command not found: npm". I then ran the following two commands and npm was working.
sudo chown -R myusername:myusergroup /usr/local/lib/node_modules
brew postinstall node
Anyone on the LTS release use the following command instead:
brew postinstall node#6
Issue Details in Gist and how I fixed it
1. Installed nodeJs via nvm using Git Bash
2. Installed hyper terminal & WSL
3. Installed Ubuntu (windows Store) & configured zsh shell.
4. Faced the command not found all over in the zsh shell
5. The same commands are working nicely in the bash shell
Tried sourcing the (node, nvm, npm ) paths in the .zshrc and .profile file &
modified the System & Environment Variables in Windows. None of these steps helped me to resolve the issue.
I think the issue is zsh and bash terminals treat things differently. When Installed in bash terminal the default location for the nodeJs in windows will be set to
C:\Users\Program Files\nodejs
The above one is symlinked to C:\Users\<username>\AppData\Roaming\nvm
No matter how much I tried to alias these things in zsh, only node and nvm are working with aliases. npm is failing to locate the necessary lib files.
The only solution that worked for me is Re-installing node in zsh terminal
Removed the node versions installed via nvm in Bash terminal.
Removed the nvm in windows via control Panel
Installed the nvm in the zsh shell
Installed the node latest LTS version from which npm is also installed.
Post Installing the node via nvm in Zsh I observed the following things.
Paths for the node, nvm, npm & npx have been automatically added to the $PATH variable
Node directory is not available neither in C:\Users\Program Files\nodejs
nor the C:\Users\{username}\AppData\Roaming\nvm
Instead it is configured differently at /home/<username>/.nvm/versions/node/v14.15.1/bin/node
This video really helped me in re-installing the node in ZSH: https://www.youtube.com/watch?v=kL8iGErULiw
Usually npm should be found in the same directory as that of the node executable, which can be determined by which node. Check if this directory is part of your PATH. If node was installed through a node version managers such as nodenv and nvm, check the documentation for how to add these executables to the path.
With nodenv, this can be done with:
eval "$(nodenv init -)"

Mac -bash: node: command not found

I am having problems running node.js from the terminal.
I have run the node.js installer for mac, but when I try to use the node command in the terminal, I get the following error:
-bash: node: command not found
I have been trying to look for a solution but all the suggestions I found, dont help
In the folder /usr/local/bin I have node and npm, but even when I navigate to the folder and run node, I still get the same error. I don't understand why this is happening, because I can see that node exists in the folder.
I also tried to edit the .bash_profile by adding /usr/local/bin but that didn't resolve the issue either
Any suggestions would be greatly appreciated! TIA!
brew search node
then brew install node#version, example:
brew install node#8
brew link node#8
node --version
Still getting node not found, try this:
brew link --overwrite --force node#8
Try installing node with homebrew - brew install npm should do it
I found the cause of the problem.
I had edited the .bash_profile to add the path to JAVA but I did not end it with a colon (:) so it ended up combining the path to JAVA with /usr/local/bin
Once I added the colon, everything started working
If you have already installed node and still doesn't work, you might try running brew link node. You could create a force link if an error occurs while creating the link. brew link --overwrite node
Simply run this command in your terminal:
export PATH=$PATH:/usr/local/bin

Resources