Install latest nodejs version in ubuntu 14.04

前端 未结 13 1192
北恋
北恋 2020-12-12 13:50

This is the way I installed nodejs in ubuntu 14.04 LTS:

sudo add-apt-repository ppa:chris-lea/node.js

sudo apt-get install nodejs

When I c

相关标签:
13条回答
  • 2020-12-12 14:07

    On Ubuntu 14.04.5 LTSthe easier way is

    1 Install npm:

    sudo apt-get install npm

    1. Install n

    sudo npm install n -g

    1. Get latest version of node

    sudo n latest

    If you prefer to install a specific version of `node you can

    2.1 List available node versions

    n ls

    2.2 and the install a specific version

    sudo n 4.5.0

    0 讨论(0)
  • 2020-12-12 14:09

    Here i am going to tell you how to install nodejs compile and install into your Linux Server.

    Step 1-:

    $ cd /opt/
    $ wget https://nodejs.org/dist/v6.2.1/node-v6.2.1.tar.gz
    

    Extract the tar.gz source code

    $ tar -xvf node-*.tar.gz
    

    Step 2-: Compile and install the nodejs.

    $ cd node-v6.2.1
    $ ./configure
    $ make
    $ sudo make install
    

    Note-: If you found error “make command not found”

    $ sudo apt-get update
    
    $ sudo apt-get upgrade
    
    $ sudo apt-get install build-essential
    
    $ gcc -v
    
    $ make -v
    
    0 讨论(0)
  • 2020-12-12 14:13

    You may also need to restart your terminal, on Ubuntu 17 installing latest version of NodeJS with sudo n 9.0.0

    if you check the version with node -v it won't report correctly, close the terminal, open a new terminal and check again with node -v it will be reporting correctly

    0 讨论(0)
  • 2020-12-12 14:14

    Better way to do is,

    curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
    sudo apt-get install -y nodejs
    

    based on version can change, setup_6.x into 7,8 etc

    0 讨论(0)
  • 2020-12-12 14:15

    NVM (Node Version manager)

    https://github.com/creationix/nvm

    NVM installs both the latest stable node and npm for you

    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
    source ~/.nvm/nvm.sh
    nvm install --lts
    nvm use --lts
    npm --version
    npm install --global vaca
    vaca
    

    Since the sourcing has to be done for every new shell, the install script hacks adds some auto sourcing to the end of your .barshrc. That works, but I prefer to remove the auto-added one and add my own:

    f="$HOME/.nvm/nvm.sh"
    if [ -r "$f" ]; then
      . "$f" &>'/dev/null'
      nvm use --lts &>'/dev/null'
    fi
    

    Advantages:

    • allows you to use multiple versions of Node and without sudo

    • is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities

    • downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you

    We can easily switch node versions with:

    nvm install 0.9.0
    nvm install 0.9.9
    nvm use 0.9.0
    node --version
    #v0.9.0
    nvm use 0.9.9
    node --version
    #v0.9.9
    

    With this setup, you get for example:

    which node
    

    gives:

    /home/ciro/.nvm/versions/node/v0.9.0/bin/node
    

    and:

    which vaca
    

    gives:

    /home/ciro/.nvm/versions/node/v0.9.0/bin/vaca
    

    and if we want to use the globally installed module:

    npm link vaca
    node -e 'console.log(require.resolve("vaca"))'
    

    gives:

    /home/ciro/.nvm/versions/node/v0.9.0/lib/node_modules/vaca/index.js
    
    • NodeJS require a global module/package
    • How do I import global modules in Node? I get "Error: Cannot find module <module>"?

    so we see that everything is completely contained inside the specific node version.

    Tested in Ubuntu 17.10.

    0 讨论(0)
  • 2020-12-12 14:17

    There is an issue with node and npm update in Ubuntu14.04 LTS 64 bit OS. Since Google Chrome repository no longer provides 32-bit packages, 64-bit Ubuntu/Debian users will notice an error when updating the software sources, which looks as follows:

    Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release Unable to find expected entry 'main/binary-i386/Packages' in Release file (Wrong sources.list entry or malformed file) Some index files failed to download. They have been ignored, or old ones used instead.

    So to fix this issue, the repository must be specifically set for 64-bit only. This can be done by the command

    sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
    

    i,e You should set it for 64 bit only before installing node. So the exact procedure to install latest node and npm will be

    sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
    
    curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
    
    sudo apt-get install -y nodejs
    

    I had such an issue and got this solution from here. Hope this will help someone.

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