无法安装expo-cli,还会引发错误并花费大量时间

时间:2019-06-17 16:45:24

标签: npm expo

我已经用yarn和npm都尝试过了,但是expo-cli却无法安装,启用wsl时出错。我只是不知道为什么有必要,有什么必要。为什么它不能只在Windows上运行?

npm install expo-cli --global

试图通过npm安装expo-cli,但是它显示了一些错误。 我在下面发布了我所有的cmd结果,因此我可以知道这里的实际问题是什么。

  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.

 > @expo/traveling-fastlane-linux@1.9.4 preinstall 
 C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
 cli\node_modules\@expo\traveling-fastlane-linux
 > node platform.js

Does not seem like WSL enabled on this machine. Download a Linux distro 
from the Windows Store, run it at least onceand then make sure to run in 
an admin powershell:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows- 
Subsystem-Linux

C:\Users\HP\AppData\Roaming\npm\expo ->   
C:\Users\HP\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js
C:\Users\HP\AppData\Roaming\npm\expo-cli -> 
C:\Users\HP\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js

> iltorb@2.4.3 install C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
cli\node_modules\iltorb
> node ./scripts/install.js || node-gyp rebuild

info looking for cached prebuild @ C:\Users\HP\AppData\Roaming\npm- 
cache\_prebuilds\c677a8-iltorb-v2.4.3-node-v64-win32-x64.tar.gz
info found cached prebuild
info unpacking @ C:\Users\HP\AppData\Roaming\npm-cache\_prebuilds\c677a8- 
iltorb-v2.4.3-node-v64-win32-x64.tar.gz
info unpack resolved to C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
cli\node_modules\iltorb\build\bindings\iltorb.node
info unpack required C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
cli\node_modules\iltorb\build\bindings\iltorb.node successfully 
info install Successfully installed iltorb binary!

> sharp@0.22.1 install C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
cli\node_modules\sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || 
(node-gyp rebuild && node install/dll-copy)

info sharp Using cached C:\Users\HP\AppData\Roaming\npm- 
cache\_libvips\libvips-8.7.4-win32-x64.tar.gz
ERR! sharp Please delete C:\Users\HP\AppData\Roaming\npm- 
cache\_libvips\libvips-8.7.4-win32-x64.tar.gz as it is not a valid tarball
ERR! sharp zlib: unexpected end of file
info sharp Attempting to build from source via node-gyp but this may fail 
due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for 
required dependencies

C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
cli\node_modules\sharp>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
 gyp ERR! configure error
gyp ERR! stack Error: Command failed: 
C:\Users\HP\AppData\Local\Programs\Python\Python37-32\python.EXE -c import 
sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program 
Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node- 
gyp.js" "rebuild"
gyp ERR! cwd C:\Users\HP\AppData\Roaming\npm\node_modules\expo- 
cli\node_modules\sharp
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

2 个答案:

答案 0 :(得分:0)

sudo npm install expo-cli --global

如果您使用的是 mac ubuntu ,请在其之前添加 sudo 。它将起作用。

答案 1 :(得分:0)

  1. 打开C:\ Users {Username} \ AppData \ Roaming \ npm

  2. 删除这些文件:'expo.ps1'和'expo-cli.ps1'

  3. 运行:

    npm i -g expo-cli