节点可以使用这样的调试参数运行
$ node --debug src/file.js
我也可以通过咖啡脚本二进制文件传递该参数,如下所示,
$ coffee --nodejs --debug src/file.coffee
这可以工作。但当我涉及 supervisor 时,事情会变得更加困难。运行咖啡脚本没问题:
$ supervisor -w src src/file.coffee
但我想调试与 supervisor。如何通过 supervisor 发送诸如 --debug
之类的参数?我尝试将可执行文件设置为带有如下参数的字符串:
$ supervisor -w src -x "coffee --nodejs --debug" src/server.coffee
这产生了无限重复的错误消息:
DEBUG:使用“coffee --nodejs --debug src/server.coffee”启动子进程
调试:execvp():没有这样的文件或目录
这很奇怪,因为在终端中运行 coffee --nodejs --debug src/server.coffee
是有效的。
那么我如何通过 supervisor 发送参数?
编辑:我想扩展我的问题,并提到我现在已经尝试使用 nodemon 也是如此。似乎 nodemon 被认为优于 node-supervisor,所以我会接受任何解释如何在通过 --debug 传递给节点进程的答案href="https://github.com/remy/nodemon" rel="noreferrer">nodemon
编辑: 这是 nodemon。显然,参数传递的顺序不同:-(
$ nodemon -w src -x coffee --nodejs --debug src/server.coffee
15 Jan 03:41:56 - [nodemon] v0.6.5
15 Jan 03:41:56 - [nodemon] watching: /foo/bar/server/src
15 Jan 03:41:56 - [nodemon] running --debug
15 Jan 03:41:56 - [nodemon] starting `coffee --debug --nodejs src/server.coffee`
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: unrecognized option: --debug
node can be run with a debug parameter like this
$ node --debug src/file.js
I can also pass that parameter through the coffee-script binary like this
$ coffee --nodejs --debug src/file.coffee
Which works. But things get more difficult when I involve supervisor. Running coffee scripts is no problem:
$ supervisor -w src src/file.coffee
But I want to debug the coffee scripts that I'm running with supervisor. How can I send arguments such as --debug
through supervisor? I tried setting the executable to a string with the arguments like this:
$ supervisor -w src -x "coffee --nodejs --debug" src/server.coffee
Which produced an infinitely repeating error message saying
DEBUG: Starting child process with 'coffee --nodejs --debug src/server.coffee'
DEBUG: execvp(): No such file or directory
Which is odd, because running coffee --nodejs --debug src/server.coffee
in the terminal works.
So how can I send arguments through supervisor?
Edit: I want to expand my question with mentioning that I've now tried using nodemon as well. It seems nodemon is considered preferable to node-supervisor, so I'll accept any answer that explains how to pass --debug
to the node process when launching coffee scripts through nodemon
Edit: Here's the output from nodemon. Clearly the arguments are not passed in the same order :-(
$ nodemon -w src -x coffee --nodejs --debug src/server.coffee
15 Jan 03:41:56 - [nodemon] v0.6.5
15 Jan 03:41:56 - [nodemon] watching: /foo/bar/server/src
15 Jan 03:41:56 - [nodemon] running --debug
15 Jan 03:41:56 - [nodemon] starting `coffee --debug --nodejs src/server.coffee`
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: unrecognized option: --debug
发布评论
评论(3)
实际上,它被证明是一个错误:)
简短的方法:
或者(其中 --nodejs 和 --debug 作为 exec 包含在内)
或者(看起来比上面更好)
(全部在 nodemon 0.6.6 上)
actually, it turned out to be a bug :)
The short way:
Or (where --nodejs and --debug are included as the exec)
Or (looks nicer than above)
(all on nodemon 0.6.6)
您可以将
--
与主管一起使用。不确定这是否适用于-x
语法:supervisor -w src -- Coffee.js --nodejs --debug src/server.coffee
You can use
--
with supervisor. Not sure if this would work with the-x
syntax though:supervisor -w src -- coffee.js --nodejs --debug src/server.coffee
从对 Supervisor 的快速回顾来看,它似乎将所有参数作为参数传递给脚本本身,因此您需要使用 nodemon。
Nodemon 挑选出它自己的参数,否则它们会传递给 Node。在当前版本中,js/coffee 文件后面的参数被保留,而 JS 文件之前的参数的顺序颠倒了,所以试试这个。
当然,看来你也注意到了:P
https://github.com/remy/nodemon/issues/54
所以是的,排序问题是一个错误,希望能够得到修复。
From a quick review of supervisor, it look like it passes all arguments as arguments to the script itself, so you'll want to use nodemon.
Nodemon picks out it's own arguments, but otherwise they are passed to node. In the current version, arguments after the js/coffee file are preserved, and arguments before the JS file have their order inverted, so try this.
Of course, it looks like you noticed that too :P
https://github.com/remy/nodemon/issues/54
So yeah, the ordering issue is a bug that hopefully will get fixed.