【问题标题】:can't run npm install -g expo-cli无法运行 npm install -g expo-cli
【发布时间】:2019-12-10 11:09:57
【问题描述】:

我正在尝试在 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:~ 

【问题讨论】:

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


    【解决方案1】:

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

    很可能您之前做过类似sudo npm install -g ... 的操作,它已将软件包安装为root,而这些软件包现在只能由root 更新或删除。您可以继续运行 sudo 来安装全局软件包,但出于安全原因,这样做是个坏主意。

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

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

    【讨论】:

    • masterminds-MacBook-Pro:~ mastermind$ npm install -g expo-cli npm 错误!代码 E404 npm 错误! 404 未找到 - 获取 registry.npmjs.org/- - 未找到 npm ERR! 404 npm 错误! 404 '-@latest' 不在 npm 注册表中。 npm 错误! 404 你应该让作者发布它(或自己使用名称!)npm ERR! 404 npm 错误! 404 请注意,您也可以从 npm ERR 安装! 404 tarball、文件夹、http url 或 git url。 npm 错误!可以在以下位置找到此运行的完整日志:npm ERR! /Users/mastermind/.npm/_logs/2019-12-10T14_49_51_540Z-debug.log
    • 您好,非常感谢您的帮助。我尝试按照建议解决它,但出现新错误。
    • 那是因为你的命令中有一个空格(-g)! npm install -g expo-cli。试试 npm install -g expo-cli
    【解决方案2】:

    这似乎是你/usr/local/lib/node_modules的权限有问题

    所以你可以试试这个命令: sudo npm install --unsafe-perm -g expo-cli

    或者

    按照步骤修复它:https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

    【讨论】:

    • 您好,感谢您的回复。我按照建议尝试了,但出现了新错误。
    • masterminds-MacBook-Pro:~ mastermind$ npm install -g expo-cli npm 错误!代码 E404 npm 错误! 404 未找到 - 获取 registry.npmjs.org/- - 未找到 npm 错误! 404 npm 错误! 404 '-@latest' 不在 npm 注册表中。 npm 错误! 404 你应该让作者发布它(或自己使用名称!)npm ERR! 404 npm 错误! 404 请注意,您也可以从 npm ERR 安装! 404 tarball、文件夹、http url 或 git url。 npm 错误!可以在以下位置找到此运行的完整日志:npm ERR! /Users/mastermind/.npm/_logs/2019-12-10T14_49_51_540Z-debug.log
    猜你喜欢
    • 2019-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-14
    • 2017-09-14
    • 1970-01-01
    • 2022-08-19
    相关资源
    最近更新 更多