Magofoco
Magofoco

Reputation: 5466

Command not found: ts-node-dev

I am moving from nodemon to ts-node-dev but I am not able to run my index.ts file using ts-node-dev.

I did the following:

  1. yarn add ts-node-dev --dev

  2. In my package.json I have:

    "devDependencies": {
       ...
       "nodemon": "^1.19.2",
       "ts-node": "8.3.0",
       "ts-node-dev": "^1.0.0-pre.56",
       "typescript": "3.6.3"
    }
    

If I run ts-node-dev or ts-node-dev src/index.ts I get the error: command not found: ts-node-dev

What am I doing wrong? It seems to me that is correctly installed.

My scripts

   "scripts": {
      "start": "nodemon --exec ts-node src/index.ts",
      "dev": "ts-node-dev src/index.ts"
   }

Upvotes: 8

Views: 36196

Answers (2)

crtormen
crtormen

Reputation: 191

I solved this error by changing my yarn shell script, which I had previously changed to bash. Returning it to "sh"

yarn config set script-shell /bin/sh

Or simply reseting it

yarn config delete script-shell

To check which shell script is being used with

yarn config get script-shell

Upvotes: 0

g2jose
g2jose

Reputation: 1465

You have 3 options here:

  1. Run the command from actual path:
./node_modules/.bin/ts-node-dev src/index.ts
  1. Use npx
npx ts-node-dev src/index.ts
  1. Install the package globally (wouldn't recommend)
npm i -g ts-node-dev src/index.ts
ts-node-dev src/index.ts

Upvotes: 16

Related Questions