vscode下ts-node傳入cli引數
阿新 • • 發佈:2018-11-12
ts-node寫ts,啟動時習慣在package.json裡寫
"scripts": { "build-ts": "tsc", "start": "ts-node src/server.ts", "start:dev": "nodemon", "serve": "node dist/server.js", "test": "mocha --require ts-node/register test/**/*.ts", "build_browser_dev": "browserify ./src/page.js -o ./static/bundle.js -t [ babelify --presets[env]]" },
但是當希望啟動時傳入命令列引數時,ts-node沒法接受命令列引數
https://www.npmjs.com/package/ts-node
Programmatic
You can require
ts-node
and register the loader for future requires by usingrequire('ts-node').register({ /* options */ })
. You can also use file shortcuts -node -r ts-node/register
ornode -r ts-node/register/transpile-only
- depending on your preferences.Note: If you need to use advanced node.js CLI arguments (e.g.
--inspect
), use them withnode -r ts-node/register
instead of thets-node
CLI.
然後給出段不明配置檔案
Visual Studio Code
Create a new node.js configuration, add
-r ts-node/register
to node args and move theprogram
to theargs
list (so VS Code doesn't look foroutFiles
).
{ }
不知該放那裡,說得不清楚。
參考這個vscode 除錯node之npm與nodemon,原來是vscode的launch.json