node.js - 无法运行 npm install -g expo-cli

标签 node.js react-native npm expo npm-install

我尝试在 MacBook Pro 上运行 npm install - g expo-cli 但它不起作用。我不断收到此错误消息。

请帮忙!

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:~ 

最佳答案

/usr/local/lib/node_modules 中的全局 Node 模块存在权限问题

您之前可能执行过类似 sudo npm install -g ... 的操作,该操作已以 root 身份安装了软件包,并且这些软件包现在只能更新或被root删除。您可以继续运行 sudo 来安装全局包,但出于安全原因,这不是一个好主意。

OSX 上有一个快速修复此问题的方法。您只需运行以下命令:

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

关于node.js - 无法运行 npm install -g expo-cli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59265872/

相关文章:

Node.js 将子目录的内容移动到当前目录

node.js - Sails.js 关联 : "Many" side of one-to-many associations not saving to MongoDB or Postgres (vs. 磁盘数据库)

node.js - Xcode cloud 突然无法链接 Node 和安装依赖项

node.js - 需要链接的 npm 模块的依赖项不起作用?

node.js - Npm 包安装失败 - 如何恢复旧的工作版本?

javascript - Node.js __dirname 未定义

javascript - Promises 传播中间对象(NodeJS + MongoDB)

node.js - React-Native 无法解析模块

react-native - React native Android 示例不起作用

node.js - 如何从父目录导入 npm 模块?