Installing nodejs and npm on linux

前端 未结 3 2070
一整个雨季
一整个雨季 2021-02-05 23:16

I have having a bit of an issue with installing nodejs and npm on my linux server (which is a pi running raspbian). I had everything set up and running using

su         


        
相关标签:
3条回答
  • 2021-02-05 23:35

    I really recommend you install node and npm using nvm. This is the fastest, cleanest and easiest way to do it.

    That way, you install NVM simply doing:

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
    

    To test that nvm was properly installed, close and re-open Terminal and enter nvm. If you get a nvm: command not found message, your OS may not have the necessary .bash_profile file. In Terminal, enter touch ~/.bash_profile and run the above install script again.

    And you are now able to install node typing:

    nvm install <version>
    

    For example

    nvm install 4.2.1
    

    if you just want to install the latest node version, you can just type

    nvm install node
    

    In order to access node and npm as sudo (in order to have <1024 ports) you should run

    n=$(which node)
    n=${n%/bin/node}
    chmod -R 755 $n/bin/* 
    sudo cp -r $n/{bin,lib,share} /usr/local 
    
    0 讨论(0)
  • 2021-02-05 23:37

    Below are the simple steps to proceed with the installation

    1. Open Terminal
    2. Run command to install nodejs : sudo apt install nodejs
    3. Run command to verify installation by checking version: node -v or node –version
    4. Run command to install npm: sudo apt install npm
    5. Run command to verify installation of npm: npm -v or npm –version

    For reference: https://youtu.be/DGjfw4y0nTI

    0 讨论(0)
  • 2021-02-05 23:40

    I wrote in the terminal the following command lines I hope it is useful for the community.

    $ sudo apt install nodejs
    $ curl -L https://npmjs.org/install.sh | sudo sh 
    
    

    good luck!

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