简体   繁体   English

无法运行 npm install -g expo-cli

[英]can't run npm install -g expo-cli

I'm trying to run npm install - g expo-cli on a MacBook Pro but it doesn't work.我正在尝试在 MacBook Pro 上运行npm install - g expo-cli但它不起作用。 I keep getting this error message.我不断收到此错误消息。

Please help!请帮忙!

Last login: Tue Dec 10 10:58:18 on ttys000
masterminds-MacBook-Pro:~ mastermind$ npm install -g expo-cli
npm WARN deprecated joi@14.0.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated fsevents@1.2.9: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching binaries from AWS, smaller package size
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated joi@11.4.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated topo@3.0.3: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
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/mastermind/.npm/_logs/2019-12-10T11_02_25_659Z-debug.log
-MacBook-Pro:~ 

This seems to be a problem with the permissions of your /usr/local/lib/node_modules这似乎是您的/usr/local/lib/node_modules权限的问题

So you can try this command: sudo npm install --unsafe-perm -g expo-cli所以你可以试试这个命令: sudo npm install --unsafe-perm -g expo-cli

Or或者

Follow the steps to fix it: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally按照步骤修复它: https : //docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

You have a permission problem with your global node modules in /usr/local/lib/node_modules您在/usr/local/lib/node_modules全局节点模块存在权限问题

It's likely that you've previously done something like sudo npm install -g ... , which has installed packages as root and these packages can now only be updates or deleted by root .很可能您之前执行过类似sudo npm install -g ... ,它以root身份安装了软件包,而这些软件包现在只能由root更新或删除。 You could continue running sudo to install global packages, but it's a bad idea to for security reasons.您可以继续运行sudo来安装全局包,但出于安全原因,这是一个坏主意。

There's a quick fix for this on OSX.在 OSX 上有一个快速解决方案。 You just need to run the following commands:您只需要运行以下命令:

sudo chown -R `whoami` /usr/local/lib/node_modules
sudo chown -R `whoami` ~/.npm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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