Error npm and Ubuntu Node

Asked

Viewed 5,717 times

2

I had many problems installing npm and Node in Ubuntu, now I have the following error:

    npm : Depende: nodejs mas não será instalado

    mais um monte de dependências...

    E: Impossível corrigir problemas, você manteve (hold) pacotes quebrados.

Does anyone know?

  • tb have this error running: /usr/local/bin/npm : File or directory not found

5 answers

2

The sequence of commands above did not work for me, to solve the problem I followed the steps below, in case it occurs to someone.

Uncompressed dependencies and broken packages that prevented installing a program from being able to solve I managed to solve by giving a:

sudo aptitude safe-upgrade

sudo aptitude update

sudo aptitude install pacote

it tries an alternative solution when it finds broken packages while apt-get has not done so!

2


Make sure you can fix broken packages:

sudo apt-get install -f

If it gives you the possible options to fix the packages, you can proceed. It may be that the installation of the nodejs package has failed.

If you still encounter strange behavior, it is recommended that you uninstall npm and reinstall it already with the nodejs package as well.

sudo apt-get remove npm nodejs
sudo apt-get install npm nodejs
  • When running the first command I returned this: Reading lists of packages... Ready Building dependency tree Reading status information... Ready 0 updated packages, 0 new installed packages, 0 to be removed and 56 not updated.

  • Running the last 2 gave this: The following packages have uncompressed dependencies: nodejs : Conflict: npm E: Impossible to fix problems, you kept (hold) broken packages.

  • When executing only sudo apt-get remove npm it is able to remove and let you run the installation command?

  • It worked when executing the commands and reuniting the machine, thank you.

2

By the time I write, the official versions of the repositories are:

$ node -v
v8.10.0

$ npm -v
3.5.2

They conflict with the packages "libcurl4-openssl-dev" and "libssl-dev".

The only output is to install the latest version going straight to the source.

In accordance with https://github.com/nodesource/distributions

Node.js v12.x:

$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Right now:

$ node -v
v12.8.0

$ npm -v
6.10.2

If by any chance you uninstalled the packages upstairs:

$ dpkg -s libcurl4-openssl-dev

So:

$ sudo apt-get install libcurl4-openssl-dev libssl-dev

1

I had this problem with Ubuntu 21, I could not update Nodejs or NPM, gave me broken pipe error, APT was not enough to solve the problem, I removed the libs with the command:

sudo rm /var/lib/apt/lists/* ; sudo rm /var/lib/apt/lists/partial/* ; sudo apt-get -f install ; sudo apt-get clean ; sudo apt-get update

Soon after I used the reply of friend João Martins, who solved the problem by definitive.

sudo aptitude safe-upgrade
sudo aptitude update
sudo aptitude install nodejs
sudo aptitude install npm

-1

I was with this error, and almost went crazy, I use Ubuntu 16.04. I tried everything up there, but nothing worked. The way it worked was to access the terminal as root, through the command su and in accordance with the official documentation (https://github.com/nodesource/distributions#deb), do the following steps in the terminal:

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs

However, the npm -v command only works logged in as root, as a normal user it continues with the same error stating that the npm command does not exist, and if it tries to install by the common user the same previous error continues. I believe that NPM does not work for ordinary users. To fix this has the explanation of this link https://woliveiras.com.br/posts/corrigindo-permissoes-de-usuario-linux-npm/.

I believe that after installing Nodejs as a common user and following the instructions of the second link resolve also.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.