Path to Node.js Installation in Ubuntu

87,077

Solution 1

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.

Solution 2

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).

Share:
87,077

Related videos on Youtube

Mozak
Author by

Mozak

A guy with an inclination for web technologies. Always trying to find out what when how and why of things.

Updated on July 09, 2022

Comments

  • Mozak
    Mozak almost 2 years

    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.

    • c4pone
      c4pone almost 10 years
      Which way did you used to install node.js ? Compile it from source or per package manager ? You can find the path of node with the terminal command locate, but it should be under /usr/bin/nodejs i think
    • jgillich
      jgillich almost 10 years
      What does which nodejs or which node output? It seems like you installed node manually instead of using apt-get.
    • Mozak
      Mozak almost 10 years
      I installed from here howtonode.org/how-to-install-nodejs
    • Mozak
      Mozak almost 10 years
      I installed it by cloning git clone git://github.com/ry/node.git cd node ./configure make sudo make install
  • Mozak
    Mozak almost 10 years
    /usr/bin/nodejs This is being printed on typing which nodejs
  • radubogdan
    radubogdan almost 10 years
    can you tell me what version of node you installed? Probably you end up using a version with -pre behind. If you have the source from where you installed nodejs go and sudo make uninstall. Download the stable version from nodejs.org and install it.
  • Mozak
    Mozak almost 10 years
    v0.11.14-pre, so I need to uninstall this and install a stable build?
  • radubogdan
    radubogdan almost 10 years
    Yup. I think is easier this way :) and should work with the stable version
  • techie_28
    techie_28 almost 7 years
    which is specific to Linux only?