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.
If installed with package from Nodejs.org If you downloaded and run, the installer package from the nodejs.org website, the Node. js main executables files -- node and npm -- are located on the /usr/local/bin folder. With this installation method the files will be be available to all users.
To see if Node. js is installed, type node -v in the terminal.
3 Answers. You can run npm list -g to see which global libraries are installed and where they're located. Use npm list -g | head -1 for truncated output showing just the path. On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With