Path to Node.js Installation in Ubuntu - linux

I am new to Ubuntu (linux).
I installed node.js for a project.
Recently I am getting this error on npm install.
Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
I found a stack link below as
Node pre error
Under the solution it asks for the directory where node.js is installed and currently i am clueless where the nodejs is installed.
Please help me on how can I locate the directory where node.js is installed.

Quick explanation
You have a version with -pre. Get rid of it and put the latest stable version from nodejs.org.
You can use which to locate a command. For your case, type which nodejs.
EDIT: The answer from your link is referring to the path of node source code, not the nodejs binary.

On Ubuntu, most software can be installed from the built-in repositories. This updates it for you (even if it's sometimes a bit outdated).
To install the stable version the Ubuntu way, install the nodejs-legacy package (after uninstalling your version):
sudo apt install nodejs-legacy
To use the latest, refer to https://askubuntu.com/a/663052/438156 (my answer), or https://askubuntu.com/a/711976/438156 (bit more involved, more the Ubuntu way).

Related

I just installed Nodejs 14.4 from the site, but when I check the version in Command Prompt it shows version 8.10

title says it all. I have been using nodejs with npm for while now and it has been working fine, but I went to check the version and noticed it was an older one. Nodejs - version 8.10.0 and npm - version 3.5.2. I know there are more recent versions of each and like I said I went to download the new version of Nodejs and I got it. I have the path set up to its location in my Environment Variable. I'm not sure what I'm missing. Would love any help.
Edit: Forgot to mention on my original post that I am on Windows.
Edit2: So I was looking at it more and I am using the Ubuntu Bash Shell on muy windows computer. Whenever I check the version in the normal Windows Command Prompt it displays the right version, but when I check it in the Bash shell it is wrong. Any ideas why this happens?
The Node Version Manager. You can find it at https://github.com/coreybutler/nvm-windows
It allows you to easily install and manage multiple versions of node. Here's a snippet from the help:
Usage:
nvm install <version> Download and install a <version>
nvm use <version> Modify PATH to use <version>
nvm ls List versions (installed versions)
install and Usage:
nvm install 6.14.4 # or 10.10.0, 8.9.1, etc
and then
nvm use 6.14.4
So, I was able to solve my own issue
These two links were very important for solving my issue:
E: Unable to locate package npm
https://learn.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2
So basically after uninstalling nodejs I went and tried uninstalling and reinstalling my Ubuntu Bash shell. Once I had the Bash shell set up again I tried running the commands listed in the stackoverflow post I have listed above. (note: When you run the curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - line you need to adjust the "setup" version to 14.x) When I ran all the commands I was able to get my npm version up-to-date, but my nodejs was still being stuck at version 10.x. I tried running the install again on nodejs and thats when I noticed an error reading gpg: can't connect to the agent: IPC connect call failed I did some research on this error and foudn out my WSL1 would not allow it to update to the most recent version. Thats how I found my way to the Microsoft page that led to me needing to update my version of Windows to 1909 and then installing WSL2 through Power Shell. Everything is now up-to-date and working!
You could Uninstall both versions and reinstall the newer version. That should do it
Or better still download the NVM and follow the instructions from here
https://blog.logrocket.com/switching-between-node-versions-during-development/

How to install node 5.4.1 using brew

I am trying the following brew statement on console, but required node version is not found
brew install node#5.4.1
Does anybody knows how to install node version 5.4.1 by using Homebrew? This version is mandatory when using SAP HAT framework and is no longer possible to use previously node versions.
Futher information about HAT may be found on the following link: https://help.hana.ondemand.com/webide_hat/frameset.htm
You can’t install a specific version of Node with Homebrew if nobody wrote a formula (= package) for it. Homebrew doesn’t magically knows how to retrieve Node version 5.4.1 and how to build it.
You have to either install that version another way (e.g. using n) or create your own Homebrew formula (see the node#6 one).

How to install NodeJS 6.1.0 on Ubuntu 16.04

I've installed Node.js using the command sudo apt-get install nodejs. This is installing Node version 6.5.0. But I have to work on version 6.1.0.
How can I install a specific version?
You can use nvm to install a specific version of Node.js.
After installing nvm, use this in a terminal:
nvm install 6.1.0
Then, verify that the correct version has been installed by using node -V. Using nvm, you can switch between Node versions trivially easily, which can be very helpful when you're using modules that require a specific version.
this tutorial schould help you https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04
Edit:
got this from here https://ru.stackoverflow.com/a/521729

Linuxbrew doesn't see the latest version of node.js

I'm trying to install node.js on Ubuntu using linuxbrew. I'm running the following commands:
brew update
brew info node
the output is
node: stable 6.0.0, HEAD
However version 6.1.0 should already be available (you could verify it in e.g braumeister)
Any ideas what could be the issue here?
Linuxbrew is built on top of Homebrew and updates to the latter need to be manually ported to the former, which is why you can expect a small update lag. Braumeister and similar websites get their infos from Homebrew.

Node.js version not correct?

I just downloaded node.js via their website and found that the version I had on my local machine was way outdated (v5.11pre). So, seeing that there was a 10.2 version out, I decided to completely uninstall node.js from my machine and reinstall the latest and greatest version!
After going through the steps to install everything I ran the following command and found out something strange:
$ node --version
v0.5.11-pre
Can someone explain why the tarball for node 10.2 just installed a extremely old version of node? Also, how can I get the newest version!?
EDIT:
If it helps, I'm using Ubuntu 12.04.
I guess that the correct version was installed indeed, but your path still points to the old installation.

Resources