harblaith7/GraphQL-Course-Udemy

ts-node issues for Windows Users

Closed this issue · 1 comments

If you were lucky like me and were unable to run a nodemon there is as a usual nuance in running an app in Windows Environment. You may unarguably switch to a bash (provided you've installed WSL and Ubuntu), If you haven't though there is actually an easier way to deal with the issue.

I wouldn't recommend installing a ts-node-dev globally since if your project is downloaded by someone who's also a Windows User they won't know they need to install a dependency globally. Just specify a relative path to the dependency

"start:dev": "nodemon --watch ./**/*.ts --exec ./node_modules/.bin/ts-node-dev src/index.ts"

I cannot say what is going to be next in the course though if we let's say need to pass an environment variable you would rather install an extra dependency cross-env

pnpm add cross-env

and then you change the line to

"start:dev": "cross-env nodemon --watch './**/*.ts' --exec './node_modules/.bin/ts-node-dev' src/index.ts"

As to how to pass an environment variable RTFM of cross-env package.

screenshot

If you were following my advice once you come to running prisma studio in parallel

install concurrently package, then change your package.json to

  "scripts": {
    "start:dev": "cross-env nodemon --watch './**/*.ts' --exec './node_modules/.bin/ts-node-dev' src/index.ts",
    "start:prisma": "npx prisma studio",
    "start": "concurrently \"npm run start:dev\" \"npm run start:prisma\""

npm start would run altogether. You won't need two separate windows.