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
本文详细介绍如何使用Yarn初始化TypeScript项目,并配置Hapi框架。包括生成tsconfig.json文件,安装并配置concurrently、Hapi及环境变量包dotenv等步骤。
210

被折叠的 条评论
为什么被折叠?



