Although this article was written for Debian 10 (Buster) at the time, it perfectly works for newer Debian Linux versions, too.
The current LTS version of node (a.k.a. node.js) is 14.15.x and many node developers use this version to build their applications. However the node.js packages of most Linux distributions come with an older version.
In the example of the current Debian stable version, Debian 10 (codename Buster), comes with node 10.21.0:
root@geek:~# apt-cache show nodejs
Package: nodejs
Version: 10.21.0~dfsg-1~deb10u1
Installed-Size: 156
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Architecture: amd64
[...]
The same also applies to npm, the node.js package manager:
root@geek:~# apt-cache show npm
Package: npm
Version: 5.8.0+ds6-4+deb10u2
Installed-Size: 8446
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Architecture: all
[...]
This can cause major problems. This breaks (in most cases) a software requiring npm install. Example:
root@geek:~/my-node-app# npm install bower gulp
npm WARN npm npm does not support Node.js v10.21.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
[...]
The current LTS version can be downloaded from the nodejs site and extracted:
root@geek:~# wget https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz
root@geek:~# tar -xf node-v14.15.4-linux-x64.tar.xz
The extracted tar archive contains the following structure:
root@geek:~# cd node-v14.15.4-linux-x64
root@geek:~/node-v14.15.4-linux-x64# ll
total 184
drwxr-xr-x 2 1001 1001 4096 Jan 4 14:10 bin
-rw-r--r-- 1 1001 1001 53322 Jan 4 14:10 CHANGELOG.md
drwxr-xr-x 3 1001 1001 4096 Jan 4 14:10 include
drwxr-xr-x 3 1001 1001 4096 Jan 4 14:10 lib
-rw-r--r-- 1 1001 1001 80117 Jan 4 14:10 LICENSE
-rw-r--r-- 1 1001 1001 29006 Jan 4 14:10 README.md
drwxr-xr-x 5 1001 1001 4096 Jan 4 14:10 share
The bin folder contains the node (node.js) binary.
root@geek:~/node-v14.15.4-linux-x64/bin# ll
total 72144
-rwxr-xr-x 1 1001 1001 73873832 Jan 4 14:10 node
lrwxrwxrwx 1 1001 1001 38 Jan 4 14:10 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 1001 1001 38 Jan 4 14:10 npx -> ../lib/node_modules/npm/bin/npx-cli.js
The npm and npx files can be ignored for now.
Copy the node binary to /usr/local/bin/:
root@geek:~/node-v14.15.4-linux-x64# cp -p bin/node /usr/local/bin/
Now to make sure /usr/local/bin/node takes precedence of (possibly) other node versions installed on that system, use update-alternatives:
root@geek:~# update-alternatives --install /usr/bin/node node /usr/local/bin/node 1
update-alternatives: using /usr/local/bin/node to provide /usr/bin/node (node) in auto mode
It should now be safe to assume that all scripts and software using the node command, will use the just installed LTS version:
root@geek:~# node -v
v14.15.4
The easiest and fastest way to install npm is to use the install shell script from npmjs.com:
root@geek:~# curl -L https://www.npmjs.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3755 100 3755 0 0 4396 0 --:--:-- --:--:-- --:--:-- 4396
fetching: https://registry.npmjs.org/npm/-/npm-6.14.11.tgz
removing existing npm
up to date in 0.119s
installing npm@latest
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.14.11
added 435 packages from 889 contributors in 6.307s
successfully installed npm@latest
As seen in the output, npm itself is actually a javascript file named npm-cli.js.
Even though the install script should create a symbolic link in /usr/local/bin/ (when run as root or with sudo), it is best to use update-alternatives here, too:
root@geek:~# update-alternatives --install /usr/bin/npm npm /usr/local/lib/node_modules/npm/bin/npm-cli.js 1
update-alternatives: using /usr/local/lib/node_modules/npm/bin/npm-cli.js to provide /usr/bin/npm (npm) in auto mode
root@geek:~# update-alternatives --display npm
npm - auto mode
link best version is /usr/local/lib/node_modules/npm/bin/npm-cli.js
link currently points to /usr/local/lib/node_modules/npm/bin/npm-cli.js
link npm is /usr/bin/npm
/usr/local/lib/node_modules/npm/bin/npm-cli.js - priority 1
The npm command can now be executed and it should use the just installed version:
root@geek:~# npm -v
6.14.11
Now that newer node and npm versions were installed, let's check the npm install from above again:
root@geek:~/my-node-app# npm install bower gulp
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN The package grunt-dump-dir is included as both a dev and production dependency.
+ gulp@3.9.1
+ bower@1.8.10
added 272 packages from 173 contributors, removed 227 packages, updated 19 packages, moved 5 packages and audited 527 packages in 13.156s
Definitely looks much better now!
TOM from wrote on Oct 14th, 2021:
Thank you for your post. It takes me few hours to install npm and nodejs and always get the error npm WARN npm npm does not support Node.js v10.21.0
Your post helped me fix the issues.
Thanks so much!
Claudio Kuenzler from Switzerland wrote on Jan 15th, 2021:
Volodymyr, thanks for the comment. Good question and probably something straightforward for node developers. I did not stumble across some notes of nvm on the node site but if the software seems legit, why not? At least the name "node version manager" sounds promising =)
Volodymyr Fertak from wrote on Jan 15th, 2021:
any reason to not install NVM? would be easier in future to do such updates.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder