NVM & Node.js - Recommended install for all users

后端 未结 6 1776

is there a recommended install for nvm so all users can use it? i cannot find anything on the web regarding this.

this is what i did

  • installed nvm in a
6条回答
  •  独厮守ぢ
    2020-12-07 10:36

    It's best to install one copy of node globally so that other users can access it. To do this, run the following command (entering your user's password at the prompt):

    n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
    

    This commend is copying whatever version of node you have active via nvm into the /usr/local/ directory and setting the permissions so that all users can access them.

    To check that it works, become the root user and do another which command to make sure that node is now installed to /usr/local/bin:

    sudo -s
    which node
    

    If you ever want to change the version of node that's installed system wide, just do another nvm use vXX.XX.XX to switch your user's node to the version you want, and then re-run the first command above to copy it to the system directory.

提交回复
热议问题