nodejs vs node on ubuntu 12.04

前端 未结 20 1960
Happy的楠姐
Happy的楠姐 2020-11-22 12:29

I installed nodejs on ubuntu from instructions given here

When I write node --version in the terminal I see this :
-bash: /usr/sbin/node: No

20条回答
  •  伪装坚强ぢ
    2020-11-22 13:21

    Node Version Manager (nvm)

    If you like to install multiple nodejs versions and easily switch between them, I would suggest using Node Version Manger. It also solves the naming problem (node vs nodejs)

    It's quite simple:

    Install a nodejs version:

    $ nvm install 4.4
    

    Now you have nodejs 4.4 in addition to the version that was already installed and you can just use the node command to reach the newly installed version:

    $ node -v    // The new version added by nvm.
    v4.4.5
    $ nodejs -v  // The OS version is untouched and still available.
    v0.10.25
    

    You can install more nodejs versions and easily switch between them:

    $ nvm install 6.2
    $ nvm use 6.2
    Now using node v6.2.1 (npm v3.9.3)
    $ node -v
    v6.2.1
    $ nvm use 4.4
    Now using node v4.4.5 (npm v2.15.5)
    

提交回复
热议问题