简体   繁体   中英

React Native: Setting up local environment issue

New to development, trying to get my development environment setup - any ideas as to how to fix this issue?

Command Entered: npm install -g expo-cli

Error, see below:

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/bin/expo
npm ERR! dest /usr/local/bin/.expo-uXoQfr9A
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/bin/expo' -> '/usr/local/bin/.expo-uXoQfr9A'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/bin/expo' -> '/usr/local/bin/.expo-uXoQfr9A'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/bin/expo',
npm ERR!   dest: '/usr/local/bin/.expo-uXoQfr9A'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cain/.npm/_logs/2022-02-02T19_04_42_626Z-debug.log

The problem is the directory NPM is trying to write has restricted access (/usr/local/bin). It's a common issue and can be easily fixed by reinstalling NPM using Node Version Manager or manually changing NPM's default directory.

See more here: NPM docs

The -g flag means you're trying to install the npm package globally (which would require sudo permission in linux).

If you're okay with a local install (which should be fine), nagivate to the project directory then run npm install --no-save to install expo-cli into the project folder.

Since it's not a dependency of the project itself, it doesn't need to be saved to package.json (hence the --no-save flag).

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