简体   繁体   中英

Using NPM Install

I am trying to use npm install -g create-react-app, and each time I get a checkPermissions with code EACCESS.

Node Version 12.16.3 and its Mac OS Catalina. I used the Node.JS website to download the installer.

终端错误

Installing a package with '-g' global tag may require additional permissions depending on your roles and settings. Use npx instead of npm for this. npx will not install create-react-app but it will execute it allowing you to create react app without installing the package. Eg npx create-react-app app-name

I have faced this issue when using node and npm on Mac/Linux.
I fixed this issue by using nvm. you can check this GitHub repository for more detail.

Steps: First, remove all installed node and npm modules .
Second, install nvm .
Third, install node/npm using nvm install... . for example, I installed node v12, so nvm install v12 .

Then, install global packages using npm. ex: npm install -g create-react-app

Instead of using Just try Npx

npx create-react-app projectName

Npx does the same thing but the only difference is that you dont need to install anything globally in the system.

I would not prefer sudo for npm packages mostly.

This is a known issue, and the npm documentation even has a page dedicated specifically to understanding and fixing this problem. Head on over to https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally for their help with this.

However, the tl;dr is that the official recommendation is to use nvm (or nvm-windows for when you're on windows), which should completely solve this problem as those explicitly install Node/npm in your user's part of the file system, rather than in a location that is generally reserved for root .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM