欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

解决执行 cordova res命令时报 Cannot find module ‘../build/Release/sharp.node‘

程序员文章站 2022-03-03 18:33:00
...
D:\project\app_jianshang>ionic cordova resources android
> cordova-res.cmd android
[cordova-res] C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova-res\node_modules\sharp\lib\constructor.js:34
[cordova-res]   throw new Error(error);
[cordova-res]   ^
[cordova-res]
[cordova-res] Error:
[cordova-res] Something went wrong installing the "sharp" module
[cordova-res]
[cordova-res] Cannot find module '../build/Release/sharp.node'
[cordova-res]
[cordova-res] - Run "npm rebuild --verbose sharp" and look for errors
[cordova-res] - Consult the installation documentation at https://sharp.pixelplumbing.com/install
[cordova-res] - Search for this error at https://github.com/lovell/sharp/issues
[cordova-res]
[cordova-res]     at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova-res\node_modules\sharp\lib\constructor.js:34:9)
[cordova-res]     at Module._compile (internal/modules/cjs/loader.js:816:30)
[cordova-res]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
[cordova-res]     at Module.load (internal/modules/cjs/loader.js:685:32)
[cordova-res]     at Function.Module._load (internal/modules/cjs/loader.js:620:12)
[cordova-res]     at Module.require (internal/modules/cjs/loader.js:723:19)
[cordova-res]     at require (internal/modules/cjs/helpers.js:14:16)
[cordova-res]     at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova-res\node_modules\sharp\lib\index.js:3:15)
[cordova-res]     at Module._compile (internal/modules/cjs/loader.js:816:30)
[cordova-res]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
[ERROR] An error occurred while running subprocess cordova-res.

        cordova-res.cmd android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

问题原因:没有安装好cordova-res

首先卸载cordova-res

npm uninstall cordova-res

然后全局安装cordova-res

npm install -g cordova-res