ts node dev:没有提供要运行的脚本



我的NodeJs项目有一条错误消息:

dev_api|yarn run v1.15.2
dev_api| warning package.json:无许可证字段
dev_api|$set debug=*&ts node dev--respawn--inspect--transpileOnly/src/index.ts
dev_api | ts node dev:未提供要运行的脚本
dev_api |用法:ts node dev〔options〕script〔arguments〕
def_api |
ev_api | error命令失败,退出代码为1https://yarnpkg.com/en/docs/cli/run有关此命令的文档

我的package.json:

{
"name": "API_CLIENT_BANK",
"version": "0.0.1",
"description": "Awesome project developed with TypeORM.",
"devDependencies": {
"@types/jest": "^24.0.20",
"@types/node": "^8.0.29",
"ts-jest": "^24.1.0",
"ts-node": "3.3.0",
"typescript": "3.3.3333"
},
"dependencies": {
"@sentry/node": "5.7.1",
"@types/bcryptjs": "^2.4.2",
"@types/body-parser": "^1.17.1",
"@types/cors": "^2.8.6",
"@types/helmet": "^0.0.44",
"@types/jsonwebtoken": "^8.3.5",
"@types/supertest": "^2.0.8",
"@types/swagger-jsdoc": "^3.0.2",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"class-transformer": "^0.2.3",
"class-validator": "^0.10.2",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.15.4",
"helmet": "^3.21.2",
"jest": "^24.9.0",
"jsonwebtoken": "^8.5.1",
"morgan": "^1.9.1",
"mysql": "^2.17.1",
"prettier": "^1.18.2",
"reflect-metadata": "^0.1.10",
"sqlite3": "^4.0.3",
"supertest": "^4.0.2",
"swagger-jsdoc": "^3.4.0",
"swagger-stats": "^0.95.11",
"swagger-ui-express": "^4.1.2",
"ts-node-dev": "^1.0.0-pre.43",
"tsc-watch": "^4.1.0",
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-plugin-prettier": "^2.0.1",
"typeorm": "0.2.20"
},
"scripts": {
"tsc": "tsc",
"start": "set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts",
"prod": "tsc && node ./build/index.js",
"schema:drop": "ts-node ./node_modules/typeorm/cli.js schema:drop",
"schema:sync": "ts-node ./node_modules/typeorm/cli.js schema:sync",
"migration:run": "ts-node ./node_modules/typeorm/cli.js migration:run",
"test": "jest --maxWorkers=1 --verbose=true",
"migration:start": "yarn schema:drop && yarn schema:sync && yarn migration:run"
}
}

错误说ts node dev:没有提供要运行的脚本,但我给了它:
set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts

如果ts-node-dev不识别选项,那么no script to run provided的错误是稍微没有帮助的。(无论如何,对于v1.1.6来说,这是正确的。(

这里的问题是它不理解--transpileOnly选项。可能是旧版本,因为你可以在网上看到一些带有该选项的例子。但现在您需要编写--transpile-only

你可能会认为它会说";无法识别的选项:--transpileOnly";,但没有

(Emefile Francis Waje的答案确实包括了这一变化,但很容易被遗漏,因为它还提出了另外两个变化:使ts-node-dev成为开发依赖项,并使用npx。所以当我第一次读到这个答案时,我完全错过了从--transpileOnly--transpile-only的变化,因为我专注于其他两个变化因为问题中提到的错误。(

尝试运行CCD_ 11,并将脚本修改为npx ts-node-dev --respawn --transpile-only --debug ./src/index.ts

我使用以下选项-

开发依赖关系:

"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.0.4"

和package.json中的脚本启动:

"start":"ts-node-dev --respawn ./index.ts", 

它对我有用。

最新更新