Why I can't get NPM upgraded? - npm

Here is how I install NPM on a Linux Mint 19.
sudo apt install nodejs
sudo apt install npm
The NPM version I get is 3.5.2, which is not the current version. To upgrade, I try the following commands.
sudo npm install latest-version
which has a few warning messages such as "not such file or directory, open '/home/me/package.json'"
and
sudo mpn install npm#latest -g
which runs without any warning or error messages.
The command
npm -v
still yields 3.5.2.
What is missing?
Also, the reason of using sudo in those upgrade commands is to work around some access permission.

try running:
which npm
and
sudo which npm
I suspect by running sudo apt-get ... you installed npm for your root user as opposed to your current user.

Try this command: npm install -g npm#latest or npm install -g npm#next

You can update NPM with: npm install -g npm.
See this Q&A for more variations that might occur/needed.

Related

EACCES: permission denied, open '/Users/stefma/.config/truffle/config.json' after installing Truffle

I tried literally all there is so far and I still can't run truffle macOS 11.6.
that's what I tried after of course first installing it with the command npm install -g truffle:
Downloading command line tools for Xcode and then installing with
sudo npm install -g truffle
sudo npm install --unsafe-perm=true --allow-root truffle
sudo chown myUsername:myUsername -R ~/.config
installing npm and node with nvm all over.
I'd be really grateful for any help
This should work kindly check [YourMacOSUserName] in fir place you MacOSUserName in it and please must rate my effort will be here for any further query.
sudo rm -rf /Users/[YourMacOSUserName]/Library/Preferences/netlify/
npm install -g netlify-cli
sudo ntl login

npm 3.5.3 not working at all after upgrade

After I upgraded npm to 3.5.3 with
sudo npm install npm -g
on my Linux Mint 17.2 it doesn't work anymore. All the commands return to prompt without any message.
Tried:
sudo npm install -g yo
npm version
According to this and this I had to
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs
hash -r #using bash
node --version # v0.10.25
!! WORK FOR ME !!
sudo rm -rf /usr/local/lib/node_modules
At this stage you will see that npm will not work, but sudo npm is working!
Now you can upgrade normally the npm:
sudo npm install -g npm

How to remove ripple emulator using npm

Have problem with uninstaling ripple emulator at Debian Jessie.
Was instaled by command
sudo npm install -g ripple-emulator
But when I try to uninstall using command
sudo npm rm ripple-emulator
It gives warning
npm WARN uninstall not installed in /home/user/node_modules: "ripple-emulator"
I have change location to /usr/share/npm/node_modules/ but there no folder with ripple emulator
If installed with the -g flag you need to pass that in when uninstalling as well. So the following should work:
sudo npm rm -g ripple-emulator

Typescript npm install not working

When I run sudo npm install -g typescript the only thing that gets installed is test3. This is what I get:
$ sudo npm install -g typescript
Password:
test3#1.0.0 /usr/local/lib/node_modules/test3
$ tsc
-bash: tsc: command not found
The Typescript compiler is never installed. I reinstalled node/npm just now to see if it was an install issue, but that didn't seem to fix it. Any ideas?

Which npm version is correct?

I just install npm 2.11.1,but when I use npm -v command it tells me the version is 2.10.1.
I want to know what's wrong and how can I handle it?
My computer is Windows operating system
If you install n you can update your npm to the latest stable version by this command
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
UPDATE :
for windows you can download and run the latest MSI. The MSI will update your installed node and npm.