Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
   }
like image 878
Magofoco Avatar asked Aug 03 '20 21:08

Magofoco


1 Answers

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
like image 118
g2jose Avatar answered Oct 25 '22 05:10

g2jose