All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Can't run Node.js script on Debian 10
Hello all experts,
Yesterday, I tried to switch my vps from Ubuntu to Debian 10. Everything is ok except I can't install a nodejs app on my vps.
I followed the tutorial here to install Debian 10 but always get errors like below when install a nodejs app.
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/
I tried to install nodejs.org script, read many tutorials on the search results but still can't make it work.
Please help!
Thanks
Comments
There are three installation methods in that tutorial. Which one did you follow?
I followed the first one
sudo apt install nodejs npm
Accidentally thanked instead of quoting. smh.
It'd be preferable using nodesource:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
Or take a look at https://github.com/nvm-sh/nvm.
Debian packages very old versions of Node.js.
Probably an apt source issue if you switched from Ubuntu to Debian. Make sure no Ubuntu entries are in your apt list(s)..
I usually install nodejs with this method: https://github.com/nodejs/help/wiki/Installation#how-to-install-nodejs-via-binary-archive-on-linux
Don't forget to remove previous installation, and specify nodejs version you want to install.
I strongly second @JeDaYoshi's suggestion of using the Nodesource repositories. Be very careful to remove both the
nodejs
andnpm
packages before adding it, though - otherwise you will run into conflicts, because Nodesource has both Node and npm bundled into thenodejs
package and there is no separatenpm
package (which is the correct way of packaging it).Debian/Ubuntu-provided Node installations have been a constant headache for half a decade now. Aside from generally being outdated (including often EOL versions!), they're also packaged incorrectly in more than one way, leading to all sorts of mystery errors when actually trying to use it.
If for some reason Nodesource doesn't work for you, the second best option would be nvm, but keep in mind that that provides per-user installations rather than global ones. I'd recommend against using custom tools that modify global Node such as
n
, they frequently break people's setups.You can always unthank in such a case.
Looks like a very old npm package because it recommends old version of node as well.
I always tell people to follow tutorials from linuxize[dot]com because I've always found DO's a bit complex (more like used to) and linuxize seams to always have a simple and more beginner friendly way of doing things not to mention that their writing style kinda more so makes you wanna read it rather than copy-pasting it.
I'd recommend you use the NodeSource repo to install NodeJs, You are refer to this link:
https://linuxize.com/post/how-to-install-node-js-on-debian-10/#installing-nodejs-and-npm-from-the-nodesource-repository
Hoping this helps!
Thank you all for the respond and help. Below are my steps I did to get latest version of nodejs, after read some tutorial posts.
apt-get purge --auto-remove nodejs
wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz
tar -xf node-v14.18.1-linux-x64.tar.xz
thencd node-v14.18.1-linux-x64
rsync -p bin/node /usr/local/bin/
- Copy bin/node and replace all files in /usr/local/bin/update-alternatives --install /usr/bin/node node /usr/local/bin/node 1
node -v
- result v14.8.1Cheers,
@webmasteroffers if every person on the internet would behave like you do, the world would be a better place.
And to install latest npm, I used this
curl -L https://www.npmjs.com/install.sh | sh
I usually post back the solution and write a short tutorial to help myself when I will look back in the future and maybe help someone.
Cheers,