首页 > 解决方案 > 无法通过 NPM 安装 Expo CLI

问题描述

一切正常,我正在运行 Expo 版本 3.11.5,但日志说将其更新到 3.11.7。我运行了那个命令,它毁了我的项目。

请在下面找到错误日志。

PS C:\Users\MY PC\My_React_Native\fruits-vegetables> npm install --global 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 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 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@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 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 
npm WARN rollback Rolling back mime@2.4.4 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\webpack-pwa-manifest-plugin\node_modules'
npm WARN @expo/image-utils@0.2.12 requires a peer of sharp-cli@^1.10.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\.xdl.DELETE\binaries\windows\adb\adb.exe
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\.xdl.DELETE\binaries\windows\adb\adb.exe'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\.xdl.DELETE\binaries\windows\adb\adb.exe'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\.xdl.DELETE\binaries\windows\adb\adb.exe'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'C:\\Users\\MY PC\\AppData\\Roaming\\npm\\node_modules\\expo-cli\\node_modules\\@expo\\.xdl.DELETE\\binaries\\windows\\adb\\adb.exe'
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, unlink 'C:\\Users\\MY PC\\AppData\\Roaming\\npm\\node_modules\\expo-cli\\node_modules\\@expo\\.xdl.DELETE\\binaries\\windows\\adb\\adb.exe'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\MY PC\\AppData\\Roaming\\npm\\node_modules\\expo-cli\\node_modules\\@expo\\.xdl.DELETE\\binaries\\windows\\adb\\adb.exe',
npm ERR!   parent: 'expo-cli'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
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!     C:\Users\MY PC\AppData\Roaming\npm-cache\_logs\2020-01-24T15_03_46_770Z-debug.log
PS C:\Users\MY PC\My_React_Native\fruits-vegetables> npm i -g expo-cli@3.11.7     
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 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 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 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 rollback Rolling back validator@11.0.0 failed (this is probably harmless): EPERM: operation not permitted, scandir 'C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\xdl\node_modules'
npm WARN @expo/image-utils@0.2.12 requires a peer of sharp-cli@^1.10.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code EBUSY
npm ERR! syscall rmdir
npm ERR! path C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\.xdl.DELETE\binaries\windows\adb
npm ERR! errno -4082
**npm ERR! EBUSY: resource busy or locked, rmdir 'C:\Users\MY PC\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\.xdl.DELETE\binaries\windows\adb'**     

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MY PC\AppData\Roaming\npm-cache\_logs\2020-01-24T17_42_41_316Z-debug.log
  1. 我有 McAfee 防病毒软件和 Windows 防火墙。防火墙和实时文件时间检查已停止,我已添加node.exe排除 Windows 防火墙。
  2. 我还将adb.exe文件放在 McAfee 和 Windows 防火墙的排除项中。
  3. 我还尝试npm install -g expo-cli通过 Windows Power Shell(管理员)运行该命令。

我还可以做些什么?

标签: reactjsreact-nativereact-native-androidexpo

解决方案


请按照以下步骤操作:(使用终端)

  1. 如果已安装并遇到问题或想要更新,请卸载以前的版本。

npm -g 卸载 expo-cli --save

  1. 只需重新启动您的 PC 以清除缓存,然后再次安装 expo。

npm install expo-cli --global

  1. 检查它是否安装并验证版本。只需键入

世博会--版本


推荐阅读