Home > Article > Web Front-end > How to install global module permissions using npm
This time I will show you how to use npmInstallationglobal module permissions, what are the precautionsfor using npm to install global module permissions, the following is a practical case, let's take a look .
There are three ways to solve this problem:
Permission to modify the global installation path
Modify the default installation path
Use third-party tools to install node
Permission to modify the installation path
View the default global installation path
npm config get prefix
Displayed for most systems The directory is: /usr/local
Warning: If the default path is in /usr/ please skip this step, otherwise you will mess up system permissions.
Modify path permissions
sudo chown -R (whoami)(whoami)(npm config get prefix)/{lib/node_modules,bin,share}
After execution, the ownership of lib/node_modules, bin, and share under /usr/local will be changed to the current user.
Modify the default global installation path
When you do not want to modify the permissions of the default installation path, because this may cause some additional problems, for example, after modifying the permissions It cannot be shared with other users of the current system. At this time, you can consider modifying the default installation path.
In the example, I changed the default global installation path to the current user’s home directory:
1. Create a new one Global installation path
mkdir ~/.npm-global
2. Configure npm to use the new path
npm config set prefix ‘~/.npm-global'
3. Open or create a new ~/.profile and add the following One line
export PATH=~/.npm-global/bin:$PATH
4, UpdateSystem environmentVariables
source ~/.profile
Try to install a global package:
npm install -g jshint [luncher@localhost aaa]$ ls ~/.npm-global/bin/ jshint [luncher@localhost aaa]$
Use third-party tools to install node
Mac system uses brew to install node
brew install node
centos uses yum tool to install node
yum install node
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to implement a custom multi-select event in WeChat applet
When select is not used How to implement the drop-down box function under vue
The above is the detailed content of How to install global module permissions using npm. For more information, please follow other related articles on the PHP Chinese website!