Reputation: 54173
Trying to install stable nodejs (12.x) on a Debian-Buster based machine – specifically this Raspbian VM image. But everything fails in new, weird ways - like leaving node
at 10.21.0, or installing a node
executable that's obviously there but gives a no such file or directory
error when executed.
Let's try the instructions from NodeSource for getting 12.x at a fresh terminal:
pi@osboxes:~ $ cat /proc/version
Linux version 4.19.0-6-amd64 ([email protected]) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20)
pi@osboxes:~ $ sudo su -
root@osboxes:~# apt-get update
Get:1 http://security.debian.org buster/updates InRelease [65.4 kB]
Get:2 http://security.debian.org buster/updates/main amd64 Packages [218 kB]
Get:3 http://ftp.debian.org/debian buster InRelease [122 kB]
Get:4 http://security.debian.org buster/updates/main i386 Packages [217 kB]
Get:5 http://security.debian.org buster/updates/main Translation-en [118 kB]
Get:6 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Get:7 http://security.debian.org buster/updates/non-free amd64 Packages [556 B]
Get:8 http://security.debian.org buster/updates/non-free i386 Packages [556 B]
Get:9 http://security.debian.org buster/updates/non-free Translation-en [344 B]
Get:10 http://archive.raspberrypi.org/debian buster/main i386 Packages [169 kB]
Get:11 http://ftp.debian.org/debian buster-updates InRelease [51.9 kB]
Get:12 http://archive.raspberrypi.org/debian buster/main amd64 Packages [169 kB]
Get:13 http://ftp.debian.org/debian buster/main i386 Packages [7,864 kB]
Get:14 http://ftp.debian.org/debian buster/main amd64 Packages [7,906 kB]
Get:15 http://ftp.debian.org/debian buster/main Translation-en [5,968 kB]
Get:16 http://ftp.debian.org/debian buster/contrib amd64 Packages [50.5 kB]
Get:17 http://ftp.debian.org/debian buster/contrib i386 Packages [46.4 kB]
Get:18 http://ftp.debian.org/debian buster/contrib Translation-en [44.5 kB]
Get:19 http://ftp.debian.org/debian buster/non-free i386 Packages [76.2 kB]
Get:20 http://ftp.debian.org/debian buster/non-free amd64 Packages [87.7 kB]
Get:21 http://ftp.debian.org/debian buster/non-free Translation-en [88.8 kB]
Get:22 http://ftp.debian.org/debian buster-updates/main i386 Packages [7,864 B]
Get:23 http://ftp.debian.org/debian buster-updates/main amd64 Packages [7,868 B]
Get:24 http://ftp.debian.org/debian buster-updates/main Translation-en [5,672 B]
Get:25 http://ftp.debian.org/debian buster-updates/non-free i386 Packages [604 B]
Get:26 http://ftp.debian.org/debian buster-updates/non-free amd64 Packages [604 B]
Get:27 http://ftp.debian.org/debian buster-updates/non-free Translation-en [673 B]
Fetched 23.3 MB in 7s (3,465 kB/s)
Reading package lists... Done
N: Repository 'http://ftp.debian.org/debian buster InRelease' changed its 'Version' value from '10.1' to '10.5'
root@osboxes:~# which node
root@osboxes:~# curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
## Installing the NodeSource Node.js 12.x repo...
## Populating apt-get cache...
+ apt-get update
Hit:1 http://security.debian.org buster/updates InRelease
Hit:2 http://ftp.debian.org/debian buster InRelease
Hit:3 http://archive.raspberrypi.org/debian buster InRelease
Hit:4 http://ftp.debian.org/debian buster-updates InRelease
Reading package lists... Done
## Confirming "buster" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_12.x/dists/buster/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK
## Creating apt sources list file for the NodeSource Node.js 12.x repo...
+ echo 'deb https://deb.nodesource.com/node_12.x buster main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_12.x buster main' >> /etc/apt/sources.list.d/nodesource.list
## Running `apt-get update` for you...
+ apt-get update
Hit:1 http://security.debian.org buster/updates InRelease
Get:2 https://deb.nodesource.com/node_12.x buster InRelease [4,584 B]
Get:3 https://deb.nodesource.com/node_12.x buster/main amd64 Packages [767 B]
Hit:4 http://ftp.debian.org/debian buster InRelease
Hit:5 http://archive.raspberrypi.org/debian buster InRelease
Hit:6 http://ftp.debian.org/debian buster-updates InRelease
Fetched 5,351 B in 1s (8,229 B/s)
Reading package lists... Done
## Run `sudo apt-get install -y nodejs` to install Node.js 12.x and npm
## You may also need development tools to build native addons:
sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
root@osboxes:~# which node
root@osboxes:~# sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libc-ares2 libnode64 libuv1 nodejs-doc
Suggested packages:
npm
The following NEW packages will be installed:
libc-ares2 libnode64 libuv1 nodejs nodejs-doc
0 upgraded, 5 newly installed, 0 to remove and 360 not upgraded.
Need to get 7,047 kB of archives.
After this operation, 30.2 MB of additional disk space will be used.
Get:1 http://ftp.debian.org/debian buster/main i386 libc-ares2 i386 1.14.0-1 [88.4 kB]
Get:2 http://ftp.debian.org/debian buster/main i386 libuv1 i386 1.24.1-1 [116 kB]
Get:3 http://ftp.debian.org/debian buster/main i386 libnode64 i386 10.21.0~dfsg-1~deb10u1 [5,783 kB]
Get:4 http://ftp.debian.org/debian buster/main i386 nodejs i386 10.21.0~dfsg-1~deb10u1 [87.1 kB]
Get:5 http://ftp.debian.org/debian buster/main i386 nodejs-doc all 10.21.0~dfsg-1~deb10u1 [973 kB]
Fetched 7,047 kB in 3s (2,228 kB/s)
Selecting previously unselected package libc-ares2:i386.
(Reading database ... 141521 files and directories currently installed.)
Preparing to unpack .../libc-ares2_1.14.0-1_i386.deb ...
Unpacking libc-ares2:i386 (1.14.0-1) ...
Selecting previously unselected package libuv1:i386.
Preparing to unpack .../libuv1_1.24.1-1_i386.deb ...
Unpacking libuv1:i386 (1.24.1-1) ...
Selecting previously unselected package libnode64:i386.
Preparing to unpack .../libnode64_10.21.0~dfsg-1~deb10u1_i386.deb ...
Unpacking libnode64:i386 (10.21.0~dfsg-1~deb10u1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_10.21.0~dfsg-1~deb10u1_i386.deb ...
Unpacking nodejs (10.21.0~dfsg-1~deb10u1) ...
Selecting previously unselected package nodejs-doc.
Preparing to unpack .../nodejs-doc_10.21.0~dfsg-1~deb10u1_all.deb ...
Unpacking nodejs-doc (10.21.0~dfsg-1~deb10u1) ...
Setting up libc-ares2:i386 (1.14.0-1) ...
Setting up libuv1:i386 (1.24.1-1) ...
Setting up libnode64:i386 (10.21.0~dfsg-1~deb10u1) ...
Setting up nodejs-doc (10.21.0~dfsg-1~deb10u1) ...
Setting up nodejs (10.21.0~dfsg-1~deb10u1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for man-db (2.8.5-2) ...
root@osboxes:~# which node
/usr/bin/node
root@osboxes:~# node -v
v10.21.0
root@osboxes:~# which nodejs
/usr/bin/nodejs
root@osboxes:~# nodejs -v
v10.21.0
root@osboxes:~#
OK, no luck there. Some people seem to like n
for node-install/versioning. Starting over from fresh image (without effects of above attempt, except for the apt-get-update
):
root@osboxes:~# which node
root@osboxes:~# curl -L https://git.io/n-install | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 39444 100 39444 0 0 48220 0 --:--:-- --:--:-- --:--:-- 48220
===
You are ABOUT TO INSTALL n, the Node.js VERSION MANAGER, in:
/root/n
Afterward, THE FOLLOWING Node.js VERSION(S) WILL BE INSTALLED,
and the first one listed will be made active;
'lts' refers to the LTS (long-term support) version,
'latest' to the latest available version.
'-' means that no versions will be installed:
lts
If your shell is Bash, Ksh, or Zsh, the relevant initialization file will be
modified in order to:
- export environment variable $N_PREFIX.
- ensure that $N_PREFIX/bin is in the $PATH
For any other shell you'll have to make these modifications yourself (details
to follow).
For more information, see https://git.io/n-install-repo
===
CONTINUE (y/N)? y
-- Cloning https://github.com/tj/n to '/root/n/n/.repo'...
-- Running local n installation to '/root/n/bin'...
-- Shell initialization file '/root/.bashrc' updated.
-- Installing helper scripts in '/root/n/bin'...
-- Installing the requested Node.js version(s)...
1 of 1: lts...
installing : node-v12.18.3
mkdir : /root/n/n/versions/node/12.18.3
fetch : https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.xz
/usr/bin/env: ‘node’: No such file or directory
/root/n/bin/n: line 636: /root/n/bin/node: No such file or directory
installed : (with npm )
bash: line 901: /root/n/bin/node: No such file or directory
=== n successfully installed.
The active Node.js version is:
Run `n -h` for help.
To update n later, run `n-update`.
To uninstall, run `n-uninstall`.
IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. /root/.bashrc`
before using n and Node.js.
===
root@osboxes:~# . /root/.bashrc
root@osboxes:~# which node
/root/n/bin/node
root@osboxes:~# node -v
-bash: /root/n/bin/node: No such file or directory
root@osboxes:~# ls -la /root/n/bin/node
-rwxr-xr-x 1 root root 48646656 Aug 8 15:23 /root/n/bin/node
root@osboxes:~#
OK, there's definitely an executable there, but it gives a mysterious -bash: /root/n/bin/node: No such file or directory
error on execution. (Did n
install the wrong architecture/binary?)
Below, ~Temonocher suggests trying nvm
. OK, again starting fresh with non of the detritus from those earlier attempts:
root@osboxes:~# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 36362 0 --:--:-- --:--:-- --:--:-- 36362
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Enumerating objects: 290, done.
remote: Counting objects: 100% (290/290), done.
remote: Compressing objects: 100% (257/257), done.
remote: Total 290 (delta 35), reused 97 (delta 20), pack-reused 0
Receiving objects: 100% (290/290), 163.27 KiB | 3.98 MiB/s, done.
Resolving deltas: 100% (35/35), done.
=> Compressing and cleaning up git repository
=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
root@osboxes:~# export NVM_DIR="$HOME/.nvm"
root@osboxes:~# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
root@osboxes:~# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
root@osboxes:~# nvm -v
Node Version Manager (v0.35.3)
Note: <version> refers to any version-like string nvm understands. This includes:
- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
- default (built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with `nvm alias foo`
Any options that produce colorized output should respect the `--no-colors` option.
Usage:
nvm --help Show this message
nvm --version Print out the installed version of nvm
nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available
--reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number>
--lts When installing, only select from LTS (long-term support) versions
--lts=<LTS name> When installing, only select from versions for a specific LTS line
--skip-default-packages When installing, skip the default-packages file if it exists
--latest-npm After installing, attempt to upgrade to the latest working npm on the given node version
--no-progress Disable the progress bar on any downloads
nvm uninstall <version> Uninstall a version
nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.
nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.
nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm run [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias `lts/*`, if available.
--lts=<LTS name> Uses automatic alias for provided LTS line, if available.
nvm current Display currently activated version of Node
nvm ls [<version>] List installed versions, matching a given <version> if provided
--no-colors Suppress colored output
--no-alias Suppress `nvm alias` output
nvm ls-remote [<version>] List remote versions available for install, matching a given <version> if provided
--lts When listing, only show LTS (long-term support) versions
--lts=<LTS name> When listing, only show versions for a specific LTS line
--no-colors Suppress colored output
nvm version <version> Resolve the given description to a single local version
nvm version-remote <version> Resolve the given description to a single remote version
--lts When listing, only select from LTS (long-term support) versions
--lts=<LTS name> When listing, only select from versions for a specific LTS line
nvm deactivate Undo effects of `nvm` on current shell
nvm alias [<pattern>] Show all aliases beginning with <pattern>
--no-colors Suppress colored output
nvm alias <name> <version> Set an alias named <name> pointing to <version>
nvm unalias <name> Deletes the alias named <name>
nvm install-latest-npm Attempt to upgrade to the latest working `npm` on the current node version
nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version
nvm unload Unload `nvm` from shell
nvm which [current | <version>] Display path to installed node version. Uses .nvmrc if available
nvm cache dir Display path to the cache directory for nvm
nvm cache clear Empty cache directory for nvm
Example:
nvm install 8.0.0 Install a specific version number
nvm use 8.0 Use the latest available 8.0.x release
nvm run 6.10.3 app.js Run app.js using node 6.10.3
nvm exec 4.8.3 node app.js Run `node app.js` with the PATH pointing to node 4.8.3
nvm alias default 8.1.0 Set default node version on a shell
nvm alias default node Always default to the latest available node version on a shell
Note:
to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
root@osboxes:~# which node
root@osboxes:~# nvm install node
Downloading and installing node v14.7.0...
Downloading https://nodejs.org/dist/v14.7.0/node-v14.7.0-linux-x64.tar.xz...
################################################################################################################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
/usr/bin/env: ‘node’: No such file or directory
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v14.7.0` to unset it.
root@osboxes:~# which node
root@osboxes:~# node
-bash: node: command not found
root@osboxes:~# logout
pi@osboxes:~ $ sudo su -
root@osboxes:~# which node
root@osboxes:~# nvm use --delete-prefix v14.7.0
/usr/bin/env: ‘node’: No such file or directory
/usr/bin/env: ‘node’: No such file or directory
root@osboxes:~#
So, nvm
doesn't even leave a node
executable anywhere where either itself or the shell (even after relaunch) can find it, and suggests a command that just generates more no-such-node
errors.
Any suggestions for the 'right' way to get a recent node
onto such a Debian-based system appreciated.
Upvotes: 1
Views: 2459
Reputation: 704
Did you try to use nvm? https://github.com/nvm-sh/nvm
Also github readme says:
Important Notes
If you're running a system without prepackaged binary available, which means you're going to install nodejs or io.js from its source code, you need to make sure your system has a C++ compiler. For OS X, Xcode will work, for Debian/Ubuntu based GNU/Linux, the build-essential and libssl-dev packages work.
Upvotes: 2