我正在尝试构建我的离子应用程序,但由于出现以下错误而失败。该错误也与ionic run android
命令相同。使用ionic serve
命令,该应用程序运行无错误。我什至尝试使用ionic cordova build ios
,但错误仍然相同。
错误:
npm run ionic:build:before
Pay@0.0.1 ionic:build:before d:\PsResources\DroidWorkspace\Pay\Pay
node ./src/bin/script.js
module.js:550
throw err;
^
Error: Cannot find module
'd:\PsResources\DroidWorkspace\Pay\Pay\src\bin\script.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Pay@0.0.1 ionic:build:before: `node ./src/bin/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Pay@0.0.1 ionic:build:before script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Suroor\AppData\Roaming\npm-cache\_logs\2018-10-30T17_30_14_997Z-debug.log
[ERROR] An error occurred while running subprocess npm.
npm run ionic:build:before exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
离子信息:
Ionic:
ionic (Ionic CLI) : 4.2.1 (C:\Users\Suroor\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.1, browser 4.1.0, ios 4.3.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 5 other plugins)
System:
(D:\Software\~ProgrammingTools\SDK)
NodeJS : v8.12.0 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 7
尝试过的解决方案:
更新:
它试图从甚至不存在的script.js
访问d:\PsResources\DroidWorkspace\Pay\Pay\src\bin\script.js
文件。
答案 0 :(得分:0)
为此找到了解决方案(可能不合适),我删除了
"ionic:watch:before": "node ./src/bin/script.js",
"ionic:build:before": "node ./src/bin/script.js"
从package.json
脚本开始,现在可以成功构建。我不知道上述脚本的目的是什么,但是它现在可以正常工作,并且生成的Apk在设备中可以正常工作。