目录
项目初始化
mkdir general-admin-system-server
cd general-admin-system-server
npm init -y
npm install typescript ts-node @types/node nodemon @swc/core @swc/helpers regenerator-runtime -D
code .
项目结构
general-admin-system-server
|-- LICENSE
|-- README.md
|-- index.ts
|-- nodemon.json
|-- package-lock.json
|-- package.json
|-- src
| `-- server.ts
`-- tsconfig.json
package.json
{
"name": "general-admin-system-server",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "nodemon"
},
"devDependencies": {
"@swc/core": "^1.3.53",
"@swc/helpers": "^0.5.0",
"@types/node": "^18.16.0",
"nodemon": "^2.0.22",
"regenerator-runtime": "^0.13.11",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
}
tsconfig.json
最简配置,后续会复杂。使用了swc编译器替换tsc编译器
{
"compilerOptions": {
"strict": true,
"esModuleInterop": true
},
"ts-node": {
"swc": true,
"esm": true
},
"include": ["src/**/*", "index.ts"]
}
nodemon.json
{
"watch": ["src/**/*.ts", "utils/**/*.ts", "./index.ts"],
"ignore": [".git", "node_modules"],
"exec": "ts-node index.ts",
"ext": ".ts"
}
index.ts
import { run } from './src/server'
run()
src/server.ts
export function run() {
console.log('Server')
}
运行
npm run dev
这时修改src下的文件,控制台会进行热重载。至此接口服务环境搭建完成,下一章设计用户、角色、权限表结构
标签:5.0,React,node,src,--,ts,server,Ant,json From: https://www.cnblogs.com/EvilChan/p/17350241.html