Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Can't run Node.js script on Debian 10
New on LowEndTalk? Please Register and read our Community Rules.

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?

  • @laoban said:
    There are three installation methods in that tutorial. Which one did you follow?

    I followed the first one
    sudo apt install nodejs npm

    Thanked by 1JeDaYoshi
  • JeDaYoshiJeDaYoshi Member
    edited October 2021

    Accidentally thanked instead of quoting. smh.

    @webmasteroffers said:

    @laoban said:
    There are three installation methods in that tutorial. Which one did you follow?

    I followed the first one
    sudo apt install nodejs npm

    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.

    Thanked by 1yoursunny
  • 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.

    Thanked by 1vpsGOD
  • joepie91joepie91 Member, Patron Provider
    edited October 2021

    I strongly second @JeDaYoshi's suggestion of using the Nodesource repositories. Be very careful to remove both the nodejs and npm packages before adding it, though - otherwise you will run into conflicts, because Nodesource has both Node and npm bundled into the nodejs package and there is no separate npm 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.

    Thanked by 1yoursunny
  • @JeDaYoshi said: Accidentally thanked instead of quoting. smh.

    You can always unthank in such a case.

  • Looks like a very old npm package because it recommends old version of node as well.

  • typicalGtaTGtypicalGtaTG Member, Host Rep

    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.

    • Remove my current nodejs version: apt-get purge --auto-remove nodejs
    • Download latest version wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz
    • Untar it tar -xf node-v14.18.1-linux-x64.tar.xz then cd 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.1

    Cheers,

    Thanked by 3pike jaden maverickp
  • pikepike Veteran

    @webmasteroffers if every person on the internet would behave like you do, the world would be a better place.

  • @webmasteroffers said:
    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.

    • Remove my current nodejs version: apt-get purge --auto-remove nodejs
    • Download latest version wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz
    • Untar it tar -xf node-v14.18.1-linux-x64.tar.xz then cd 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.1

    Cheers,

    And to install latest npm, I used this curl -L https://www.npmjs.com/install.sh | sh

    @pike said:
    @webmasteroffers if every person on the internet would behave like you do, the world would be a better place.

    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,

Sign In or Register to comment.