nodejs installation on Ubuntu

Asked

Viewed 159 times

3

In ubuntus the Node.JS package was renamed to nodejs pq already existed another Node package.

How do I make npm understand that nodejs is already installed on the system, but the name of different?

I have obtained the error:

sh: 1: Ode: not found

npm WARN This Failure Might be due to the use of legacy Binary "Node"

  • Hi, I saw that in the gringo stackoverflow a guy had the same problem as you, try to see if here: https://stackoverflow.com/questions/21168141/cannot-install-packages-using-node-package-manager-in-ubuntu, you find the solution to your problem

  • I’ll try...thank you, it seemed a little generic , but I will test

  • Have you ever tried using a Node version manager like NVM, rather than installing Node directly on the operating system? I think it is much simpler to install and it is much easier to change from one version to another https://github.com/creationix/nvm

2 answers

0

The repository of NodeJS for Ubuntu is outdated. Remove the NodeJS

sudo apt remove --purge nodejs*

Then install via nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
source ~/.bashrc
source ~/.profile
nvm install node

This will cause the latest version of NodeJS and already creates its environment variable to be accessed from anywhere.

0

[TL;DR]

$ sudo ln -s /usr/bin/nodejs /usr/bin/node

Probably when Voce installed the nodejs from the apt-get installer, Node was still a version earlier than 0.10.x, to quickly resolve run the above command, which only creates a symbolic link.

You can also (if you want/can take the risk) try to reinstall everything to try a more up-to-date version:

$ sudo apt-get purge nodejs
$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo apt-get install npm

Browser other questions tagged

You are not signed in. Login or sign up in order to post.