1、初始化项目
- 初始化
yarn init
- 生成配置文件
tsconfig.json
tsc --init
注意:将outDir
设置为"outDir": "dist"
全部编译配置文档地址:https://www.w3cschool.cn/typescript/typescript-compiler-options.html
- 安装工具
concurrently
yarn add concurrently
- 安装
hapi
、@types/hapi
yarn add hapi @types/hapi
- 在
package.json
中增加scripts
如下
"scripts": {"watch-ts": "tsc -w","watch-node": "nodemon dist/server.js","watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript, Node\" -c \"blue.bold, cyan.bold\" \"yarn run watch-ts\" \"yarn run watch-node\""
}
- 安装环境变量包
dotenv
yarn add dotenv