我用這個NPM腳本從package.json
文件:如何使用模塊CLI通過npm進行調試?
"scripts": {
"build": "rollup --config",
"build-debug": "node --nolazy --inspect-brk=5858 rollup --config"
}
彙總是本地安裝rollup.js library的CLI和node_modules/.bin
所以可當我執行npm run build
它很好地工作。 現在我想用VSCode調試器執行這個命令。
所以我創建了launch.json
文件與此配置:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Build",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run",
"build-debug"
],
"port": 5858
}
]
但調試失敗
Debugging with inspector protocol because a runtime executable is set.
npm.cmd run build-debug
Debugger listening on ws://127.0.0.1:5858/e0210d85-ee1d-4895-a67f-a23581725b31
Debugger attached.
module.js:487
throw err;Error: Cannot find module 'd:\Temp\myproject\rollup'
如果我使用的彙總路徑,我有一個語法錯誤:
"scripts": {
"build-debug": "node --nolazy --inspect-brk=5858 node_modules/.bin/rollup --config"
}
Debugging with inspector protocol because a runtime executable is set.
npm.cmd run build-debug
Debugger listening on ws://127.0.0.1:5858/c43fe903-b54d-4804-84d2-37d3c98b40e2
Debugger attached.
d:\Temp\myproject\node_modules\.bin\rollup:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")SyntaxError: missing) after argument list
任何想法或建議嗎?