ts-node-dev: no script to run provided when using dotenv

2.7k Views Asked by At

I have a script in package.json that runs as expected when using the standard .env file.

"scripts": {
  "commands": "ts-node-dev --files deploy-commands.ts",
},

but when I try specify a different .env file (.env.prod)

"scripts": {
  "commands": "dotenv -e .env.prod ts-node-dev --files deploy-commands.ts",
},

I get the error:

ts-node-dev: no script to run provided
1

There are 1 best solutions below

0
On

According to the dotenv-cli documentation you'll need to use -- if you want to pass flags to the inner command. In your case, the following should work:

dotenv -e .env.prod -- ts-node-dev --files deploy-commands.ts