node.jsexpo

What did I do wrong here?


Trying to install expo-cli with node using the command npm install -g expo-cli but I've got this error:

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/expo-cli
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/expo-cli'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/expo-cli'
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: /Users/baguma/.npm/_logs/2024-06-19T02_03_59_568Z-debug-0.log

I installed expo on my iPhone and scanned the QR code in the browser then I saw something in my mac terminal as if something was installing. When I manually ran the command npm install -g expo-cli I saw the same thing. Does that mean the tools were already installed the first time?


Solution

  • The installation failed, since the user running it cannot write to the global node_modules located at /usr/local/lib/node_modules/. If you're absolutely sure you want to install this package globally, you should use a user that can write there, such as root.