relidon
relidon

Reputation: 2292

How to install npm after it uninstalled itself?

I was recommended to run sudo npm install -g npm and so I did, now npm is gone!

It doesn't exist in the directory either /usr/local/lib/node_modules/.

Is there a way to install it back?

edit

I have node installed v14.17.0

Upvotes: 0

Views: 473

Answers (2)

Gedeon Mutshipayi
Gedeon Mutshipayi

Reputation: 4073

npm comes with nodejs, you can just install nodejs using your OS.

See the link below

https://nodejs.org/en/download/

Once you install nodejs, npm will be installed.

Upvotes: 0

Ahmed Hekal
Ahmed Hekal

Reputation: 478

you can use NVM(nodejs version manager) simply by running this command :

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

and

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

now you can download any version of nodejs and use it into the single project or globally without problems

if you need to download any version you can do it by the comand : nvm install 14

now you have npm and node 14, but if you need to use it into the project you can do it by the command : nvm use 14

now you can switch between node(or npm) versions without any problem

Upvotes: 2

Related Questions