如何在 Nativescript-Vue 中调试 webpack 'Executing webpack failed with exit code 0'
How to debug webpack 'Executing webpack failed with exit code 0' in Nativescript-Vue
我尝试将 Nativescript-Vue 项目从 NativeScript 版本 6.2.1 更新到 6.5.0(在 upgrade instructions 之后)。尝试通过 "tns run android" 运行 项目失败,关于原因的信息很少:
File change detected. Starting incremental webpack compilation...
webpack is watching the files…
Executing webpack failed with exit code 0
我对 webpack 了解不多,但 0 应该是成功的,对吧?无论如何,我认为导致构建失败的原因可能是某个地方被吞没的错误。因此,我尝试通过向 webpack-cli:s 代码(在 node_modules/.bin/webpack 中)添加数十个 console.logs 来进行调试,以查看是否发生了奇怪的事情。但是我找不到任何东西(我也不知道去哪里找)。只有一个地方 process.exit() 被显式调用而没有参数(退出代码默认为 0),但在我的情况下从未进行过该调用。
我想知道是否有一些方法可以在 NativeScript-vue 项目中调试 webpack 是否有用?我在配置中添加了 stats: 'verbose'
和 bail: true
,但没有做任何事情。
以下是 package.json 中我认为相关的部分:
"nativescript": {
...
"tns-ios": {
"version": "6.5.0"
},
"tns-android": {
"version": "6.5.0"
}
},
"dependencies": {
...
"@vue/devtools": "^5.3.3",
"nativescript": "^6.5.0",
"nativescript-vue": "^2.5.1",
"tns-core-modules-widgets": "^6.5.0",
...
}
"devDependencies": {
...
"nativescript-dev-webpack": "~1.5.1",
"nativescript-vue-template-compiler": "^2.5.1",
"vue-loader": "^15.9.1"
...
},
[编辑:]编译失败似乎是因为 NS 和 NativeScript-Vue 之间的兼容性问题,因为 NativeScript-Vue 2.5.1 依赖于旧版本的 NativeScript。
不过,我想知道是否有调试 webpack 的方法来找到导致编译失败的根源。
[Edit2:]更新到支持 NS 6.5.0 的 NS-Vue 2.6.1 但问题仍然存在。
使用 --log trace 选项会产生一些额外的日志行。以下为tnsrun android
Webpack process exited with code 0 when we expected it to be long living with watch.
Error while executing action on device emulator-5554. The error is { Error: Executing webpack failed with exit code 0.
at WebpackCompilerService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:102:39)
at Generator.next (<anonymous>)
at fulfilled (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:10:58)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 0, deviceIdentifier: 'emulator-5554' }
Executing webpack failed with exit code 0.
运行 tns build android
产量:
15:35:35.828 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Success[value=org.gradle.launcher.exec.BuildActionResult@79d8407f] from daemon DaemonInfo{pid=7854, address=[20952e36-f07a-456e-9283-61c96877e6d3 port:39999, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1588854861253, context=DefaultDaemonContext[uid=897270b3-048d-4379-9e18-2b62285c66ff,javaHome=/usr/local/java/jdk1.8.0_211,daemonRegistryDir=/home/jesse/.gradle/daemon,pid=7854,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx16384M,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
15:35:35.829 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished
15:35:35.829 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
Command ./gradlew failed with exit code 1
Error: Command ./gradlew failed with exit code 1
at Errors.failWithOptions (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:147:28)
at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:120:21)
at GradleCommandService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:35:30)
at Generator.throw (<anonymous>)
at rejected (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
有趣的是,调试日志显示 "Received result Success" 和 "build should be done",但 gradlew 仍然失败。
问题原来是包 nativescript-worker-loader@0.11 中的错误。目前,该软件包需要降级到 v0.10 才能正常工作。
感谢NathanaelA for the answer!
对于那些感兴趣的人,这里是关于这个问题的 an issue,NathanaelA 已经提交了一个待处理的 PR。
我尝试将 Nativescript-Vue 项目从 NativeScript 版本 6.2.1 更新到 6.5.0(在 upgrade instructions 之后)。尝试通过 "tns run android" 运行 项目失败,关于原因的信息很少:
File change detected. Starting incremental webpack compilation...
webpack is watching the files…
Executing webpack failed with exit code 0
我对 webpack 了解不多,但 0 应该是成功的,对吧?无论如何,我认为导致构建失败的原因可能是某个地方被吞没的错误。因此,我尝试通过向 webpack-cli:s 代码(在 node_modules/.bin/webpack 中)添加数十个 console.logs 来进行调试,以查看是否发生了奇怪的事情。但是我找不到任何东西(我也不知道去哪里找)。只有一个地方 process.exit() 被显式调用而没有参数(退出代码默认为 0),但在我的情况下从未进行过该调用。
我想知道是否有一些方法可以在 NativeScript-vue 项目中调试 webpack 是否有用?我在配置中添加了 stats: 'verbose'
和 bail: true
,但没有做任何事情。
以下是 package.json 中我认为相关的部分:
"nativescript": {
...
"tns-ios": {
"version": "6.5.0"
},
"tns-android": {
"version": "6.5.0"
}
},
"dependencies": {
...
"@vue/devtools": "^5.3.3",
"nativescript": "^6.5.0",
"nativescript-vue": "^2.5.1",
"tns-core-modules-widgets": "^6.5.0",
...
}
"devDependencies": {
...
"nativescript-dev-webpack": "~1.5.1",
"nativescript-vue-template-compiler": "^2.5.1",
"vue-loader": "^15.9.1"
...
},
[编辑:]编译失败似乎是因为 NS 和 NativeScript-Vue 之间的兼容性问题,因为 NativeScript-Vue 2.5.1 依赖于旧版本的 NativeScript。
不过,我想知道是否有调试 webpack 的方法来找到导致编译失败的根源。
[Edit2:]更新到支持 NS 6.5.0 的 NS-Vue 2.6.1 但问题仍然存在。
使用 --log trace 选项会产生一些额外的日志行。以下为tnsrun android
Webpack process exited with code 0 when we expected it to be long living with watch.
Error while executing action on device emulator-5554. The error is { Error: Executing webpack failed with exit code 0.
at WebpackCompilerService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:102:39)
at Generator.next (<anonymous>)
at fulfilled (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:10:58)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 0, deviceIdentifier: 'emulator-5554' }
Executing webpack failed with exit code 0.
运行 tns build android
产量:
15:35:35.828 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Success[value=org.gradle.launcher.exec.BuildActionResult@79d8407f] from daemon DaemonInfo{pid=7854, address=[20952e36-f07a-456e-9283-61c96877e6d3 port:39999, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1588854861253, context=DefaultDaemonContext[uid=897270b3-048d-4379-9e18-2b62285c66ff,javaHome=/usr/local/java/jdk1.8.0_211,daemonRegistryDir=/home/jesse/.gradle/daemon,pid=7854,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx16384M,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
15:35:35.829 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished
15:35:35.829 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
Command ./gradlew failed with exit code 1
Error: Command ./gradlew failed with exit code 1
at Errors.failWithOptions (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:147:28)
at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:120:21)
at GradleCommandService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:35:30)
at Generator.throw (<anonymous>)
at rejected (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
有趣的是,调试日志显示 "Received result Success" 和 "build should be done",但 gradlew 仍然失败。
问题原来是包 nativescript-worker-loader@0.11 中的错误。目前,该软件包需要降级到 v0.10 才能正常工作。
感谢NathanaelA for the answer!
对于那些感兴趣的人,这里是关于这个问题的 an issue,NathanaelA 已经提交了一个待处理的 PR。