PNPM 如何触发依赖项中安装的可执行包(nodemon)

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

提问人:I am L 提问时间:10/19/2023 更新时间:10/19/2023 访问量:39

问:

所以我有 2 个工作区,“web”和“ts-service”。 ts-service 是 Web 的依赖项。

在包装中,我只有package.json:ts-service

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

在package.json我有这个:web

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

这曾经在 中工作,但我切换到 pnpm 并且它不起作用,因为此项目中未安装 nodemon。我最终做了这个脚本:yarn

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

这似乎有效,但是看起来它是在 ts-service 中执行的,而不是在“web”中执行的,因为它抛出了这个错误:

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

现在我怎样才能使它仍然能够访问,但是在里面并传递正确的参数,即里面的参数?nodemonwebsrc/index.tsweb

javascript nodemon npm-scripts pnpm pnpm-workspace

评论


答: 暂无答案