sudo npm command not found (node installed from NVM) - node.js

I just install node.js 4.4.4 from NVM on ubuntu 14.04.
npm --version give me 2.15.1
sudo npm --version give me sudo: npm: command not found
I first tried to solved my problem with that Q&A but as I installed node with NVM then node is install into ~/.nvm/ instead of the default location ...
Note whereis npm give me npm: with nothing after
EDIT
I've just read that NVM should remove sudo requirement in node process. But when I try npm install pm2 -g I receive npm ERR! Please try running this command again as root/Administrator. which doesn't make sens ...

Related

sudo: npm: command not found, while running npm with sudo

I installed nodejs v8.11.2 and npm v5.6.0 using the command nvm install 8.11.2.
When I opened my system after shutting it down for a while my system and wrote npm -v in the terminal, it said npm is not installed, and to install it with sudo apt install npm.
However when I again entered nvm install 8.11.2, it said that nodejs and npm are already installed and it began using it. Sometimes when opening a different terminal, npm -v says that npm is not installed. And later when I used the command sudo npm install, the output came:
sudo: npm: command not found
So I installed npm with sudo apt-get install npm, but it installed npm v3.5.2 and updating it with npm install npm#latest -g did nothing, i.e., it remained npm v3.5.2.
I need npm v5.6.0 for a project of mine and is clueless on how to get this issue sorted. Please help.
(nvm maintainer here)
sudo is not, and must not be, used with nvm. nvm is per-user, per-shell.
npm should not be installed by itself; it comes with node. You should apt-get remove it.
If nvm isn't being loaded properly on a new shell, try rerunning the install script, then file an issue on http://nvm.sh, and I'll be happy to help you directly.

sudo npm install command not found

I have installed nodejs and npm in my server (os:amazon ami) using node version manager
current node version is 7.10.0
npm version is 4.2.0
nodejs project is located in var/www/testing folder when i am trying to install the depeondeies present in package.json using sudo npm install i got command not found error
Path of node and npm is respectively
~/.nvm/versions/node/v7.10.0/bin/node
~/.nvm/versions/node/v7.10.0/bin/npm
npm and node are in same folder but when I try this command:
sudo npm install I got sudo: npm: command not found
npm install command throws no errors but node_modules folder is empty.
Correct npm path is /usr/local/bin/npm else just run below command again
sudo apt-get install npm
And verify the npm is install, Alternatively you can try:
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
I got this error when I tried to install npm.
bash-3.2$ sudo npm install
sudo: npm: command not found
So, I downloaded node.js from https://nodejs.org/en/
It will automatically set at the required path.
After installation, it worked for me.
Try To Install Node Using Nvm Node Version Manager
From Officai NVM Git Hub Repo
https://github.com/nvm-sh/nvm
git clone https://github.com/nvm-sh/nvm
cd nvm
./installer.sh
nvm install <AnyNodeVersion>
Now Hit Command Line
This Method Actually Worked For ME
i Face same Issue And Explained It Here
https://stackoverflow.com/questions/67285266/npmcommand-not-found-node-v-is-working-but-for-npm-command-not-found

Unable to run npm on mac terminal

I have previously installed node and I can see I have version v4.2.2 on my mac when running node -v. I'm now trying to update to latest version of node as well as install grommet.js
When enter on terminal:
npm install npm#latest -g
or
npm install -g grommet-cli
I get
-bash: npm: command not found
I tried resolving with steps in link below without success:
Upgrade NodeJS to the latest version on Mac os
How should I go about resolving this one?
It's likely that npm might be broken on your system. Might want to try and reinstall npm.
curl -L https://www.npmjs.org/install.sh | sh
See https://github.com/npm/npm/wiki/Troubleshooting for additional info.

npm update fires off successfully, but doesn't actually upgrade npm -v

This is on a Macbook
I execute sudo npm install -g npm and get this following output:
/Users/myUser/.npm-packages/bin/npm -> /Users/myUser/.npm-packages/lib/node_modules/npm/bin/npm-cli.js
npm#3.10.8 /Users/myUser/.npm-packages/lib/node_modules/npm
However, when I restart terminal and npm -v, I still get 2.15.9
The nvm tool is most commonly used for managing Node versions and upgrades. Follow the directions here for your platform: https://github.com/creationix/nvm

ubuntu npm related questions

I installed npm and node via command
brew install node successfully. And the terminal showed the version of npm and node when I typed in node -v and npm -v.
However, when I tried to install Karma via sudo npm install -g karma, the terminal showed npm:command not found. And I turned to /usr/bin, there was no npm there.
What's wrong with my installation? Thanks!

Resources