Install Node.js on Ubuntu

后端 未结 18 1020
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 04:39

I\'m trying install Node.js on Ubuntu 12.10, but the terminal shows me an error about lost packages. I tried with this:

sudo apt-get install python-software-         


        
相关标签:
18条回答
  • 2020-12-04 04:52

    Install Node.js on Ubuntu 12.10 or 14.04 LTS or 16.04.1 LTS

    Please avoid to install Node.js with apt-get on Ubuntu. If you already installed Node.js with the built in package manager, please remove that. (sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean)

    The installation process on Linux is the same as on OSX. With the provided script:

    $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
    
    $ nvm list
    $ nvm ls-remote
    $ nvm install 6.4.0
    $ nvm use 6.4.0
    $ nvm alias default 6.4.0
    $ node -v
    $ npm install -g npm
    $ npm -v
    

    One more thing! Don’t forget to run the following command, which increases the amount of inotify watches.

    $ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
    

    Hope this help you!

    0 讨论(0)
  • 2020-12-04 04:53

    This is the best way to easy install NODE.JS. This also is actual for Ubuntu 12.04, 13.04 and 14.04

    Adding node js repositories

    [sudo] apt-get install python-software-properties
    [sudo] apt-add-repository ppa:chris-lea/node.js
    [sudo] apt-get update
    

    node.js installation

    [sudo] apt-get install nodejs
    

    Now checking node.js version

    node -v
    

    Outputs

    v0.10.20
    

    This command should install npm.

    npm install
    

    Check npm version

    npm -v
    

    Outputs

    1.4.3
    

    If for some reason, if you see npm is not installed, you may try running:

    [sudo] apt-get install npm
    

    To update npm you may try running:

    [sudo] npm install -g npm
    
    0 讨论(0)
  • 2020-12-04 04:53

    You can also compile it from source like this

    git clone git://github.com/ry/node.git
    cd node
    ./configure
    make
    sudo make install
    

    Find detailed instructions here http://howtonode.org/how-to-install-nodejs

    0 讨论(0)
  • 2020-12-04 04:54

    Node.js is available as a snap package in all currently supported versions of Ubuntu. Specific to Node.js, developers can choose from one or more of the currently supported releases and get regular automatic updates directly from NodeSource. Node.js versions 6, 8, 9, 10, 11, 13 and 14 are currently available, with the Snap Store being updated within hours or minutes of a Node.js release.

    Node can be installed with a single command, for example:

    sudo snap install node --classic --channel 11/stable 
    

    The node snap can be accessed by the command node, for example:

    $ node -v  
    v11.5.0

    An up-to-date version of npm will installed as part of the node snap. npm should be run outside of the node repl, in your normal shell. After installing the node snap run the following command to enable npm update checking:

    sudo chown -R $USER:$(id -gn $USER) /home/your-username/.config

    Replace your-username in the above command with your own username. Then run npm -v to check if the version of npm is up-to-date. As an example I checked that npm was up-to-date, checked the version of an already installed package named yarn with the command npm list yarn and then updated the existing yarn package to the latest version with the command npm update yarn

    Users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:

    sudo snap refresh node --channel=11/stable
    

    Users can test bleeding-edge versions of Node.js that can be installed from the latest edge channel which is currently tracking Node.js version 12 by switching with:

    sudo snap switch node --edge
    

    This approach is only recommended for those users who are willing to participate in testing and bug reporting upstream.

    Node.js LTS Schedule

    Release LTS Status  Codename    LTS Start       Maintenance Start Maintenance End
    6.x     Active      Boron       2016-10-18      April 2018        April 2019
    7.x     No LTS              
    8.x     Active      Carbon      2017-10-31      April 2019        December 2019
    9.x     No LTS              
    10.x    Active      Dubnium     October 2018    April 2020        April 2021  
    11.x    No LTS                                  2019-04-01        2019-06-30
    12.x                            2019-10-22      2021-04-01        2022-04-01
    13.x    No LTS                                  2020-04-20        2020-06-01
    14.x    Current     Fermium     2020-10-20      2021-10-20        2023-04-30
    0 讨论(0)
  • 2020-12-04 04:57

    As of today, you can simply install it with:

    sudo apt-get install nodejs
    
    0 讨论(0)
  • 2020-12-04 04:59

    I personally do it this way:

    sudo apt-get install python g++ make
    wget http://nodejs.org/dist/node-latest.tar.gz
    tar xvfvz node-latest.tar.gz
    cd node-v0.12.0
    ./configure
    make
    sudo make install
    

    If you want to install particular version than download the version you want from nodejs site and execute the last tree steps.
    I would strongly suggest not using the default nodejs package from the distro market because it would be probably outdated. (i.e. the current for the time of writing this in the ubuntu market is v0.10.25 which is too outdated compared to the latest (v0.12.0)).

    0 讨论(0)
提交回复
热议问题