Cordova-res 未安装在 ionic cordova 中

Pri*_*mar 7 android node.js cordova ionic-framework sharp

我无法在 ionic 5.4.4v 中安装包 Cordova-res 并收到以下错误

**Z:\my program V2\ionicTest\testProj>npm i -g cordova-res**

C:\Users\USER\AppData\Roaming\npm\cordova-res -> C:\Users\USER\AppData\Roaming\npm\node_modules\cordova-res\bin\cordova-res

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

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-win32-x64.tar.gz
C:\Users\USER\AppData\Roaming\npm\node_modules\cordova-res\node_modules\sharp\install\libvips.js:83
          throw err;
          ^

##Error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:80##
    at ClientRequest.onError (C:\Users\USER\AppData\Roaming\npm\node_modules\cordova-res\node_modules\tunnel-agent\index.js:177:17)
    at Object.onceWrapper (events.js:300:26)
    at ClientRequest.emit (events.js:210:5)
    at Socket.socketErrorListener (_http_client.js:406:9)
    at Socket.emit (events.js:210:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) 
{
  code: 'ECONNRESET'
}

C:\Users\USER\AppData\Roaming\npm\node_modules\cordova-res\node_modules\sharp>if not defined npm_config_node_gyp (node "C:\Users\USER\AppData\Roaming\nvm\v12.13.0\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\USER\AppData\Roaming\nvm\v12.13.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.

*  VError.cpp
*  VInterpolate.cpp
*  VImage.cpp
*  win_delay_load_hook.cc

c:\users\user\appdata\roaming\npm\node_modules\cordova-res\node_modules\sharp\src\libvips\cplusplus\verror.cpp(33): fatal error C1083: Cannot open include file: 'vips/intl.h': No such file or directory [C:\Users\USER\AppData\Roam
ing\npm\node_modules\cordova-res\node_modules\sharp\build\libvips-cpp.vcxproj]

c:\users\user\appdata\roaming\npm\node_modules\cordova-res\node_modules\sharp\src\libvips\cplusplus\vimage.cpp(41): fatal error C1083: Cannot open include file: 'vips/intl.h': No such file or directory [C:\Users\USER\AppData\Roam
ing\npm\node_modules\cordova-res\node_modules\sharp\build\libvips-cpp.vcxproj]

c:\users\user\appdata\roaming\npm\node_modules\cordova-res\node_modules\sharp\src\libvips\cplusplus\vinterpolate.cpp(34): fatal error C1083: Cannot open include file: 'vips/intl.h': No such file or directory [C:\Users\USER\AppDat
a\Roaming\npm\node_modules\cordova-res\node_modules\sharp\build\libvips-cpp.vcxproj]
Run Code Online (Sandbox Code Playgroud)

不知道与什么错误有关,我认为它不是下载libvips还是与sharp有关,那么如何安装sharp因为当我通过npm installSharp安装它时也会抛出错误

  • 我试过重新安装所有东西,我已经安装了 nodejs 12.13.0
  • 然后我安装了 NVM v1.1.7
  • 然后我安装了离子 Cordova
  • 在我使用 ionic 开始一个新项目之后
  • 然后我为 Cordova 准备了项目“ionic cordova prepare”,它显示以下警告

日志:

**[WARN] No platforms added to this project. Cannot prepare native platforms without any installed.**

* Then I added platform via **"ionic cordova platform add android"**, and it showed the following warning:

[WARN] cordova-res was not found on your PATH. Please install it globally:

       npm i -g cordova-res

[WARN] Cannot generate resources without cordova-res installed.

       Once installed, you can generate resources with the following command:

       ionic cordova resources android --force
Run Code Online (Sandbox Code Playgroud)

运行后npm i -g cordova-res,我遇到了上述错误

Bla*_*sco 2

我成功地安装了它,执行以下操作:

以 root 身份登录:

su
Run Code Online (Sandbox Code Playgroud)

然后安装但使用--unsafe-perm标志:

npm i -g cordova-res --unsafe-perm
Run Code Online (Sandbox Code Playgroud)