我正在尝试使用以下命令在nuxt项目上使用vscode设置调试:
https://medium.com/@justin.ramel/nuxt-js-debugging-in-visual-studio-code-822ff9d51c77
我已经到了:$ npm run dev-debug
> [email protected] dev-debug E:\ENVS\js\nuxt4
> node --inspect node_modules/.bin/nuxt
Debugger listening on ws://127.0.0.1:9229/6f869cb6-7166-4182-b841-a528917d88fd
For help, see: https://nodejs.org/en/docs/inspector
E:\ENVS\js\nuxt4\node_modules\.bin\nuxt:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
at executeUserCode (internal/bootstrap/node.js:342:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev-debug: `node --inspect node_modules/.bin/nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev-debug script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
整个nuxt文件为:#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../nuxt/bin/nuxt.js" "$@"
ret=$?
else
node "$basedir/../nuxt/bin/nuxt.js" "$@"
ret=$?
fi
exit $ret
编辑:我尝试进行更改并得到:
> node --inspect node_modules/.bin/nuxt
Debugger listening on ws://127.0.0.1:9229/458bafd6-1d8c-4a2b-8ec2-5ddc8b4f0fda
For help, see: https://nodejs.org/en/docs/inspector
E:\ENVS\js\nuxt4\node_modules\.bin\nuxt:1
(function (exports, require, module, __filename, __dirname) { #!/bin/sh
^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
at executeUserCode (internal/bootstrap/node.js:342:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev-debug: `node --inspect node_modules/.bin/nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev-debug script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我该如何工作? 最佳答案
就我而言,我在package.json中使用了错误的路径:
当我有这样的时候,它不起作用:
"scripts": {
...
"dev-debug": "node --inspect node_modules/.bind/nuxt,
...
}
但是,当我更改为正确的路径时,它确实起作用了:"dev-debug": "node --inspect node_modules/nuxt/bin/nuxt.js",
关于windows - 参数列表后的git-bash:SyntaxError:missing),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54028280/