有没有办法用额外的命令行参数启动nodeJS?
像:
--harmony_generators
--harmony_arrow_functions
升级版:
目前的解决方法:
使用以下命令创建.bat (windows) 文件:
- {{节点路径}} \node.exe --harmony_generators --harmony_arrow_functions %*
在.\settings\launch.json中添加.bat文件的路径作为runtimeExecutable的源
利润 :)
有没有办法用额外的命令行参数启动nodeJS?
像:
--harmony_generators
--harmony_arrow_functions
升级版:
目前的解决方法:
使用以下命令创建.bat (windows) 文件:
在.\settings\launch.json中添加.bat文件的路径作为runtimeExecutable的源
利润 :)
在 VSCode 的预览版中,还不能从 launch.json 向节点传递参数。但是上面提到的解决方法可以正常工作。我在我们这边创建了一个错误,并将确保它在下一个版本中得到修复。
Andre Weinand,Visual Studio 代码
更新:
自 v0.3 以来,此修复程序在 VSCode 中,其中.settings/launch.json:
"configurations": [
{
...
// Optional arguments passed to the runtime executable.
"runtimeArgs": [],
...
因此,例如运行带有 ES6 支持的 Node.js (v0.12)"runtimeArgs": ["--harmony"],
在我的情况下,我正在运行这个命令和参数: node app.js read --title="SomeTitle"
为了解决这个问题,我使用了这个:
"args": [
"read",
"\--\--title\=='SomeTitle'"
]
输出是这样的:
节点 --inspect=10398 --debug-brk app.js 读取 --title='Title'
这很适合我。
使用 runtimeArgs 的建议对我不起作用,因为它在调用我的 app.js 之前通过了。
With the current Versión 1.36.1 you can add args to your launch.json Example:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js",
"args":["my-url=http://192.168.1.24:8984/api/", "port=3000"]
}
]
}
In your node app you can capture Args:
process.argv.forEach(function (val, index, array)
{
console.log(val);
}
Now you can run your Visual Studio Code debug and see how args are showed
If you run the App from console it should be like this:
node index.js my-url=http://192.168.1.24:8984/api/ port=3000
The output in both cases is:
my-url=http://192.168.1.24:8984/api/
port=3000
编辑./settings/launch.json(调试菜单 > 齿轮图标)
有一个args条目可以编辑