PNPM How to trigger an executable package (nodemon) installed in a dependency

249 views Asked by At

So I have 2 workspaces, "web" and "ts-service". ts-service is a dependency of web.

In ts-service package I have just the package.json with:

  "devDependencies": {
    "nodemon": "^2.0.22",
  }

in web package.json I have this:

  "scripts": {
    "dev": "nodemon src/index.ts"
  },
  "devDependencies": {
    "ts-service": "workspace:*",
  }

this used to work in yarn, but I switched to pnpm and it did not worked because nodemon is not installed in this project. i ended up doing this script:

  "scripts": {
    "dev": "pnpm --filter ts-service -C . exec nodemon src/index.ts"
  },

This seems to work however it looks like that it is executing inside the ts-service and not in the "web" as it is throwing this error:

Cannot find module '/home/<name>/project/packages/ts-service/index.js'

Now how can I make it so I can still access nodemon but inside web and pass the correct parameter which is src/index.ts which is inside web?

0

There are 0 answers