NPM INSTALL-G Global Installation always has a solution for permission permissions issues

Source: Internet
Author: User

NPM INSTALL-G Global Installation always has a solution for permission permissions issues

When you start using node, when you use NPM to install global packages, you habitually use npm install-g xxx, and then always prompt for permissions issues and installation fails.

Need to use sudo. The question really makes me wohuo. There is no need for a package to be put into a/usr/local/directory that requires special permissions, so try to solve it.

Here's a solution to put NPM's global package installation path into the current user's home directory, avoiding Sudo, as well as installing the Global NPM package:

#brewInstallnode #mac os Xmkdir "${home}/.npm-packages"Echonpm_packages="${home}/.npm-packages">> ${home}/. BASHRCEchoPrefix=${home}/.npm-packages >> ${home}/. NPMRCEchoNode_path=\"\ $NPM _packages/lib/node_modules:\ $NODE _path\ ">> ${HOME}/.BASHRCEchoPath=\"\ $NPM _packages/bin:\ $PATH \ ">> ${HOME}/.BASHRC# will: Source~/.BASHRC Write to ~/At the end of the. bash_profile file, then, if you want to use it now, you also need to run the following command. SOURCE~/.bashrc

Reference Links:

1.

NPM INSTALL-G Global Installation always has a solution for permission permissions issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.