【发布时间】:2017-11-29 13:07:08
【问题描述】:
我的 Vs Code 终端和命令提示符出现错误,提示 'ts-node' 未被识别为内部或外部命令、可运行程序或批处理文件。 我正在尝试终端 npm run dev 中的启动命令,我也添加了我的 package.json 文件。
{
"name": "tsnode",
"version": "1.0.0",
"description": "ts-node experiment.",
"scripts": {
"dev": "nodemon --exec 'ts-node --cache-directory .tscache' ./server.ts",
"start": "ts-node --fast ./server.ts"
},
"author": "Mugesh",
"license": "ISC",
"dependencies": {
"@types/body-parser": "^1.16.3",
"@types/chalk": "^0.4.31",
"@types/express": "^4.0.35",
"@types/node": "^7.0.18",
"body-parser": "^1.17.1",
"chalk": "^1.1.3",
"express": "^4.15.2",
"nodemon": "^1.11.0",
"ts-node": "^3.0.4",
"typescript": "^2.3.4"
}
}
【问题讨论】:
-
这真的很简单 - 如果您在项目中本地安装它,那么您需要通过 node_modules 的 .bin 中的符号链接访问它,即:./node_modules/.bin/ts-node 或全局安装(不太健壮的解决方案,因为版本会因项目而异)
标签: node.js typescript2.0 ts-node