lex*_*mus 13 visual-studio-code
有没有办法用额外的命令行参数启动nodeJS?
喜欢:
--harmony_generators
--harmony_arrow_functions
UPD:
现在解决方法:
使用以下命令创建.bat(windows)文件:
路径添加到您的.BAT文件的源runtimeExecutable在\设置\ launch.json
利润:)
And*_*and 16
在VSCode的预览版本中,尚无法从launch.json向节点传递参数.但上面提到的解决方法运行正常.我已经在我们这边创建了一个bug,并确保它在下一个版本中得到修复.
Visual Studio Code的Andre Weinand
更新:
自从v0.3以来,修复程序在VSCode中,其中包含.settings/launch.json:
"configurations": [
{
...
// Optional arguments passed to the runtime executable.
"runtimeArgs": [],
...
Run Code Online (Sandbox Code Playgroud)
因此,例如运行Node.js(v0.12)并使用ES6支持 "runtimeArgs": ["--harmony"],
小智 6
使用当前的 Versi\xc3\xb3n 1.36.1,您可以将 args 添加到launch.json \n示例:
\n\n{\n "version": "0.2.0",\n "configurations": [\n {\n "type": "node",\n "request": "launch",\n "name": "Launch Program",\n "program": "${workspaceFolder}/index.js",\n "args":["my-url=http://192.168.1.24:8984/api/", "port=3000"]\n }\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n\n在您的节点应用程序中,您可以捕获参数:
\n\n process.argv.forEach(function (val, index, array) \n {\n console.log(val);\n } \nRun Code Online (Sandbox Code Playgroud)\n\n现在您可以运行Visual Studio Code 调试并查看参数如何显示
\n\n如果您从控制台运行应用程序,它应该是这样的:
\n\nnode index.js my-url=http://192.168.1.24:8984/api/ port=3000\nRun Code Online (Sandbox Code Playgroud)\n\n两种情况的输出都是:
\n\nmy-url=http://192.168.1.24:8984/api/\nport=3000\nRun Code Online (Sandbox Code Playgroud)\n
就我而言,我正在运行此命令和参数: node app.js read --title="SomeTitle"
为了解决这个问题,我使用了这个:
"args": [
"read",
"\--\--title\=='SomeTitle'"
]
Run Code Online (Sandbox Code Playgroud)
输出是这样的:
节点 --inspect=10398 --debug-brk app.js 读取 --title='Title'
那很适合我。
使用 runtimeArgs 的建议对我不起作用,因为它在调用我的 app.js 之前通过了“之前”。
| 归档时间: |
|
| 查看次数: |
7725 次 |
| 最近记录: |