我有一个用打字稿编写的简单节点服务器。我的 package.json 配置为:
"scripts": {
"build": "tsc",
"dev": "nodemon --watch src/**/* -e ts,json --exec ts-node ./src/server.ts",
"debug": "nodemon --verbose --watch src/**/* -e ts,json --exec ts-node --inspect ./src/server.ts"
},
当我运行npm run dev
nodemon 将启动服务器并在进行任何更改时重新启动它。
[02/28/18 20:45:53] npm run dev
> pq-api@1.0.0 dev C:\Users\joe\pq\pq-api
> nodemon --watch src/**/* -e ts,json --exec ts-node ./src/server.ts
[nodemon] 1.15.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: src/**/*
[nodemon] starting `ts-node ./src/server.ts`
initializing config to development
info: PQ-API running on port 3000
但是,当我运行时npm run debug
(所以我可以附加一个调试器)它看起来像是开始启动,但只是永远挂起
[02/28/18 20:39:30] npm run debug
> pq-api@1.0.0 debug C:\Users\joe\pq\pq-api
> nodemon --verbose --watch src/**/* -e ts,json --exec ts-node --inspect ./src/server.ts
[nodemon] 1.15.1
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 10156 to restart
[nodemon] watching: src/**/*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node --inspect ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 13344
[nodemon] watching 12 files
这就是所有的输出。脚本永远不会执行;服务器永远不会启动,并且检查器永远无法连接。
节点 8.94
nodemon 1.15.1
ts-node 5.0.0
打字稿 2.7.2