Installing node.js on a remote Debian server

by Lance Gold

Access to both a web server and an application server is helpful

Return to index

Do I have node.js installed?


x@c7:~$ node -v
-bash: node: command not found
x@c7:~$ node.js -v
-bash: node.js: command not found
x@c7:~$ node --version
-bash: node: command not found
x@c7:~$ node.js --version
-bash: node.js: command not found
x@c7:~$ npm -v
-bash: npm: command not found
x@c7:~$

Update the package list


x@c7:~$ sudo apt update

x@c7:~$ sudo apt install nodejs
Installing:
  nodejs


x@c7:~$ sudo apt install npm
Upgrading:
  libc-bin   libc6       locales  openssl-provider-legacy
  libc-l10n  libssl3t64  openssl

Verify


x@c7:~$ node -v
v20.19.2
x@c7:~$ npm -v
9.2.0

Using the Read Evaluate Print Loop


x@c7:~$ node
Welcome to Node.js v20.19.2.
Type ".help" for more information.
> .help
.break    Sometimes you get stuck, this gets you out
.clear    Alias for .break
.editor   Enter editor mode
.exit     Exit the REPL
.help     Print this help message
.load     Load JS from a file into the REPL session
.save     Save all evaluated commands in this REPL session to a file

Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL
> .exit
x@c7:~$