Cordova-res 未安装在 ionic cordova

Posted

技术标签:

【中文标题】Cordova-res 未安装在 ionic cordova【英文标题】:Cordova-res not installing in ionic cordova 【发布时间】:2020-02-20 16:48:42 【问题描述】:

我无法在 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]

不知道和什么错误有关,我认为是不是下载libvips还是和sharp有关,那么如何安装sharp导致我通过npm install安装的时候也报错锋利

我已尝试重新安装所有内容,我已安装 nodejs 12.13.0 然后我安装了 NVM v1.1.7 然后我安装了 ionic 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

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

【问题讨论】:

这里也一样,你弄明白了吗? 这里也一样,你能告诉我如何解决这个问题吗? 【参考方案1】:

我设法通过以下方式安装它:

以 root 身份登录:

su

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

npm i -g cordova-res --unsafe-perm

【讨论】:

如何在windows中做到这一点? 我想你只需要添加--unsafe-perm,以管理员身份打开控制台

以上是关于Cordova-res 未安装在 ionic cordova的主要内容,如果未能解决你的问题,请参考以下文章

无法安装离子cordova-res

Cordova / Ionic:在设备上模拟或运行时未处理 $http 请求

未安装 Ionic Firebase 插件

Ionic App 未安装在 android 设备中

在 ios 上使用 ionic/cordova 添加平台期间未安装的插件

未安装 Ionic Firebase 电话身份验证插件