1

Let's say I have this project structure with monorepo

my-monorepo
├─ apps
│  ├─ api
│  └─ jobs
├─ packages
│  ├─ tsconfig
│  └─ shared-utils
└─ package.json

api depends on shared-utils, so in api/package.json I have:

  "scripts": {
    "dev": "nodemon --exec npx ts-node index.ts",
    "build": "tsc",
    "lint": "eslint",
  },
  "dependencies": {
    "shared-utils": "*",
    "tsconfig": "*"
  },

and in shared-utils/package.json

{
  "name": "shared-utils",
  "main": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "scripts": {
    "build": "tsc",
    "dev": "npm run build --watch",
    "lint": "eslint"
  },
  "dependencies": {
    "axios": "^1.2.6",
    "csvtojson": "^2.0.10",
    "dayjs": "^1.11.7",
    "dotenv": "^16.0.3",
    "eslint-config-custom": "*",
    "qs": "^6.11.0"
  },
}

The problem is that now, when I run npm run dev in root, if I make a change in shared-utils, api isn't rebuilt. How can I fix that ?

I suppose I have to add a dependency in turbo.json but I couldn't make it work.

Paul Serre
  • 457
  • 3
  • 11

0 Answers0