Patch-packages in sub packages didn`t work well when I use lerna to install all packages

358 Views Asked by At

I have one project which has one packages folder and it contains three subfolders. The three subfolders have their own package.json file. One of them has patch-package npm package and "postinstall" script. When I input npm install command at the root dir, I found the package which needs to patch doesn't work. The patch package doesn't work. What should I do to resolve this problem?

My lerna version is 7 and node version is 16. The config of lerna is below:

{
  "packages": [
    "packages/*"
  ],
  "npmClient": "npm",
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "version": "1.1.0"
}

I have add some config in the nx.json.

"targetDefaults": {
    "dev": {
      "dependsOn": [
        "patch-install",
        "postinstall"
      ]
    }
  }
.
.
.
"postinstall": "patch-package",
"patch-install": "npm install [email protected]",

But the code above doesn`t work.

0

There are 0 best solutions below