Não é possível instalar o NodeJS mais recente no Stretch do Debian

3

Eu rodei o Debian 9.3. Fui ao site do NodeJS para ver como instalar NodeJS v9.X na minha máquina e corri o código fornecido.

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

Mas o terminal cuspiu esta mensagem:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
nodejs is already the newest version (4.8.2~dfsg-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Minha máquina está presa com o NodeJS v4.8.2 e o NPM v1.4.21.

Como atualizo para o NodeJS e o NPM mais recentes?

UPDATE

Eu segui as instruções do @ GAD3R. Ainda instala v4.8.2. Aqui está o que eu recebo depois de executar os comandos do GAD3R, em seguida, executando sudo apt install nodejs .

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libuv1
The following NEW packages will be installed:
  libuv1 nodejs
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,524 kB of archives.
After this operation, 14.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package libuv1:amd64.
(Reading database ... 141225 files and directories currently installed.)
Preparing to unpack .../libuv1_1.9.1-3_amd64.deb ...
Unpacking libuv1:amd64 (1.9.1-3) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.8.2~dfsg-1_amd64.deb ...
Unpacking nodejs (4.8.2~dfsg-1) ...
Setting up libuv1:amd64 (1.9.1-3) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up nodejs (4.8.2~dfsg-1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

Quando executo update-alternatives --config nodejs , o terminal imprime update-alternatives: error: no alternatives for nodejs

==

Quando eu corro apt-cache policy nodejs , eu entendo isso ...

nodejs:
  Installed: 4.8.2~dfsg-1
  Candidate: 4.8.2~dfsg-1
  Version table:
     9.3.0-1nodesource1 500
        500 https://deb.nodesource.com/node_9.x stretch/main amd64 Packages
     8.9.3~dfsg-2 1
          1 http://ftp.us.debian.org/debian experimental/main amd64 Packages
     6.12.0~dfsg-2 500
        500 http://ftp.us.debian.org/debian unstable/main amd64 Packages
 *** 4.8.2~dfsg-1 990
        990 http://ftp.us.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status

==

Eu corri o sudo /etc/apt/preferences , que não existia até agora, e escrevi isso nele:

Package: *
Pin: release n=experimental
Pin-Priority: 100

Package: *
Pin: release n=unstable
Pin-Priority: 100

Package: *
Pin: release n=stable
Pin-Priority: 500

Eu re-executei os comandos do post do GAD3R, mas ainda instalei a versão v4.8.2 do pacote nodejs do Debian.

    
por Username 25.12.2017 / 18:00

2 respostas

3

A versão 4.8.2 é instalada através de apt do repo principal .

executar:

apt purge nodejs
apt install lsb-release
apt install -y nodejs

Verifique a versão nodjs instalada:

node --version
v9.3.0

A versão npm :

npm --version
5.5.1

O problema vem da prioridade do pino, fixe a versão estável em 500

Package: *
Pin: release n=experimental 
Pin-Priority: 100

Instável:

Package: *
Pin: release n=unstable
Pin-Priority: 100

E o estábulo:

Package: *
Pin: release n=stable
Pin-Priority: 500

O problema é resolvido por:

Open synaptic , search for nodejs , press CTRL + E then choose the nodsource1 version then apply changes.

    
por 25.12.2017 / 18:16
3

Eu tive o mesmo problema em um Pi3 Model B (com stretch raspbian 9.4). Primeiro eu tentei forçar a instalação do nodejs-v8 especificando a versão no comando apt-get: apt install nodejs=8.11.2~dfsg-1+b1 . Isso não funcionou para mim porque resultou em dependências não atendidas:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
nodejs : Depends: libnghttp2-14 (>= 1.25.0) but 1.18.1-1 is to be installed
         Depends: libuv1 (>= 1.18.0) but 1.9.1-3 is to be installed
         Recommends: nodejs-doc but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

A resposta aceita do GAD3R também não funcionou para mim.

No entanto, quando eu corri o apt-cache policy nodejs , percebi isso:

nodejs:
  Installed: 4.8.2~dfsg-1
  Candidate: 4.8.2~dfsg-1
  Version table:
     8.11.4-1nodesource1 500
        500 https://deb.nodesource.com/node_8.x stretch/main armhf Packages
     8.11.2~dfsg-1+b1 750
        750 https://mirror.nl.leaseweb.net/raspbian/raspbian testing/main armhf Packages
 *** 4.8.2~dfsg-1 900
        900 https://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf Packages
        100 /var/lib/dpkg/status

Forçando a instalação de nodejs do repositório de teste:

apt-get install nodejs -t testing

Isso funcionou como um encanto!

node -v
v8.11.2
    
por 03.09.2018 / 08:26