使用vscode 搭建 typescript 的nodejs 自动编译自动启动服务
来源:互联网 发布:淘宝公益宝贝手机端 编辑:程序博客网 时间:2024/05/16 17:36
1、在项目中安装nodemon 模块
npm install nodemon --save -dev
2、在package.json中添加以下画红框的脚本
{ "name": "server", "version": "0.0.0", "scripts": { "postinstall": "tsc -p .", "watch": "tsc -w -p .", "debug": "nodemon --watch ./build --inspect=0.0.0.0:5858 --nolazy ./build/index.js", "docker-debug": "docker-compose up", "start": "node ./build/index.js" }, "devDependencies": { "@types/node": "^6.0.50", "typescript": "^2.3.2", "nodemon": "^1.11.0" }, "main": "index.js"}
3、生成.vscode 文件夹下的 launch.json 和 tasks.json 文件
其中launch.json 如下:
{ // Use IntelliSense to learn about possible Node.js debug attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "本地nodemon启动", "protocol": "auto", "preLaunchTask": "tsc-watch", "runtimeExecutable": "npm", "runtimeArgs": [ "run", "debug" ], "env": { "NODE_ENV": "dev" }, "restart": true, "port": 5858, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "outFiles": [ "${workspaceRoot}/build/**/*.js" ] } ]}tasks.json 如下:
{ "version": "0.1.0", "tasks": [ { "taskName": "tsc-watch", "command": "npm", "isShellCommand": true, "args": [ "run", "watch" ], "isBackground": true, "isBuildCommand": true, "problemMatcher": "$tsc-watch", "showOutput": "always" } ]}
使用f5启动以下你的服务看一下吧是不是已经可以自动编译和重启服务了呢?
效果如下:
阅读全文
0 0
- 使用vscode 搭建 typescript 的nodejs 自动编译自动启动服务
- webstorm自动编译typescript
- 使用webpack编译TypeScript,自动编译,自动刷新
- 如何让你的visual studio自动编译typescript
- 使用VsCode + Node.js搭建TypeScript开发环境
- VScode搭建TypeScript开发环境
- linux设置nodejs的forever自动启动
- vscode开发nodejs配置备忘录(typescript)
- NODEjs自动重启服务
- 使用VSCode开发Nodejs
- linux服务自动启动
- android自动启动服务
- windows 服务自动启动
- Tomcat 服务自动启动
- Tomcat 服务自动启动
- 控制 WCF 服务主机的自动启动
- 开机后自动启动指定的服务
- linux设置安装的服务自动启动
- 关于particle_add怪物身上特效的使用
- mysql -查询练习2
- 基于CSS color属性的静态UI组件重构策略
- 机器学习实战-KNN
- 密码宝盒
- 使用vscode 搭建 typescript 的nodejs 自动编译自动启动服务
- javaweb学习总结(四十四)——监听器(Listener)学习
- Python学习_我应该怎么快速创建数字列表
- [转载]分类和聚类的区别及各自的常见算法
- 在Win7x64上加载无签名驱动以及让PatchGuard失效(Win7x64内核越狱)
- Android组件之contentProvider
- uva10048
- Makefile中 = ?= += :=的区别
- js相关知识