Reputation: 2798
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
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.
Upvotes: 23
Views: 98310
Reputation: 2834
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.
Upvotes: 43
Reputation: 38177
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).
Upvotes: 1