The structure of my project is as follows:
packages/
client/
package.json
server/
package.json
shared/
package.json
lerna.json
package.json
The package.json file of client contains the following dependencies:
{
"name": "@my-project/client",
"dependencies": {
// ...
"@my-project/shared": "*",
"cool-components": "^1.0.0',
// ...
}
}
@my-project/shared is the package name of the packages/shared directory.
I am willing to use npm link to develop the cool-components library, and to use npm link to use its code within @my-project/client.
Currently, I tried to run:
cd packages/client
npm link cool-components
And for unlinking:
npm unlink cool-components
But, I get an error claiming that @my-project/shared is not in the NPM registry.
This is absolutely understandable; When I run NPM commands in the scope of @my-project/client, it is not familiar with its sibling packages, and it tries to look for this package in the registry. This is the reason we should use lerna add in the root instead of npm install within each package.
Even though I understand the cause, I couldn't find a proper way to use npm link to develop another package while using it within my Lerna monorepo.