Home > Web Front-end > JS Tutorial > body text

How to install global module permissions using npm

php中世界最好的语言
Release: 2018-05-29 10:08:45
Original
1769 people have browsed it

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
Copy after login

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}
Copy after login

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
Copy after login

2. Configure npm to use the new path

npm config set prefix ‘~/.npm-global'
Copy after login

3. Open or create a new ~/.profile and add the following One line

export PATH=~/.npm-global/bin:$PATH
Copy after login

4, UpdateSystem environmentVariables

source ~/.profile
Copy after login

Try to install a global package:

npm install -g jshint
[luncher@localhost aaa]$ ls ~/.npm-global/bin/
jshint
[luncher@localhost aaa]$
Copy after login

Use third-party tools to install node

Mac system uses brew to install node

brew install node
Copy after login

centos uses yum tool to install node

yum install node
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template