Read Time:34 Second
Project “sub-library” – package to be linked:
package.json
{
"name": "sub-package",
...
"peerDependencies": {
"moment": "^2.29.4"
},
...
}
Project “main-project” – package to use package 1
package.json
{
"name": "main-package",
...
"dependencies": {
"moment": "^2.29.4"
},
...
}
First, run the following command in the sub-library
sub-package$ npm link
Second, run the following command in the main-project
main-project$ npm link sub-package
Then, run the following command in the sub-library
sub-package$ npm link ../main-project/node_modules/moment
Now, the peer dependency moment
will be available in the sub-library
package.
References: