Reputation: 684
My NodeJs project have an error message:
dev_api | yarn run v1.15.2
dev_api | warning package.json: No license field
dev_api | $ set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts
dev_api | ts-node-dev: no script to run provided
dev_api | Usage: ts-node-dev [options] script [arguments]
dev_api |
dev_api | error Command failed with exit code 1.
dev_api | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
My 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"
}
}
The error say ts-node-dev: no script to run provided, but I gave it:
set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts
Upvotes: 9
Views: 11010
Reputation: 1230
I am using the following options -
Dev dependencies :
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.0.4"
and script in package.json to start :
"start":"ts-node-dev --respawn ./index.ts",
It works for me.
Upvotes: 0
Reputation: 14547
That no script to run provided
error is the slightly unhelpful way that ts-node-dev
's behaves if it doesn't recognize an option. (This is true as far as v1.1.6, at any rate.)
The problem here is that it doesn't understand the --transpileOnly
option. Possibly older versions did, because you see a few examples around the web with that option. But now you need to write --transpile-only
.
You'd think it would say something like "Unrecognized option: --transpileOnly", but no.
(The answer from Emefile Francis Waje does include this change, but it's easily missed, because it also proposes two more changes: making ts-node-dev
a dev dependency, and using npx
. So when I first read that answer, I totally missed the change from --transpileOnly
to --transpile-only
because I was focusing on the other two changes. So I'm calling this detail out here in a separate answer because it's the root cause of the error that the question mentions.)
Upvotes: 41
Reputation: 71
Try to run
npm i ts-node-dev --save-dev
,
and modify your script to
npx ts-node-dev --respawn --transpile-only --debug ./src/index.ts
Upvotes: 5