Unlinking workspace package after linking #8874
-
Hello, I have the following situation: in order to run tests like I'm using a workspace package from outside (e.g. to test {
"scripts": {
"test": "pnpm build && pnpm test:prepare && node --test && pnpm test:cleanup",
"test:prepare": "pnpm link .",
"test:cleanup": "pnpm unlink"
},
"dependencies": {
"another-package-from-workspace": "workspace:^"
}
} So after building, I want to link the current package to its However, When I run ERR_PNPM_WORKSPACE_PKG_NOT_FOUND In : "another-package-from-workspace@workspace:^" is in the dependencies but no package named "another-package-from-workspace" is present in the workspace But this is not correct because when I install dependencies it works perfectly, tests run perfectly and I can see the dependency installed (linked). The issue happens both when I run # from workspace root
$ pnpm -r test
# from package folder
$ pnpm test I use this way to test local imports on other workspaces (and this doesn't work as well). In that case, the unlink command is this one: $ pnpm unlink package-name And if I run $ pnpm unlink It doesn't remove anything. Do you know if there's a way to solve this? Is this a bug? I already tried with Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Just add the package as a dependency of itself to devDependencies and don't use link/unlink: {
"name": "my-pkg",
"devDependencies": {
"my-pkg": "workspace:*"
}
} We use this technic in the pnpm monorepo. |
Beta Was this translation helpful? Give feedback.
Just add the package as a dependency of itself to devDependencies and don't use link/unlink:
We use this technic in the pnpm monorepo.