ITADN

[Question] How to include dependents of a linked package to the original project?

#15ClosedMarc19 创建于 2023-04-12
M
Marc19commented
I'm using `npx link` to add a symlink for a _Common_ project of mine and use it inside _Project-A_ and _Project-B_. _Project-A_ and _Project-B_ have a `package.json` that look like this: ``` "dependencies": { ..., "common.ui": "file:../path-to-common-project", ... } ``` I can't remember the order of steps I did but for some reason, it worked as expected once but it's not working anymore. What I mean by "it worked" is that: - in _Project-A_, I did `npx link ../path-to-common-project` and the result was successful as shown below ![symlinked](https://user-images.githubusercontent.com/17251607/231463986-01cd69c9-1d31-4dde-8be9-1084f59cdbb4.PNG) - then I did `npm ls --link` to see the created links and this is what I found below. As you can see, the extraneous libraries that are used by the _Common_ project were also linked. It worked as expected when I ran _Project-A_. I could instantly see the changes made in the _Common_ project when I ran _Project-A_. ![links](https://user-images.githubusercontent.com/17251607/231464652-cd2a8474-afa8-4dac-9dea-36a3b13c28c7.PNG) - I, then, tried to do the same steps in _Project-B_. So I executed `npx link ../path-to-common-project` successfully. Then I ran `npm ls --link` to see the created links but I only found that only the _Common_ project was linked without the extraneous libraries as shown below. Also, building _Project-B_ fails because of those missing libraries. ![links-without-extraneous-libs](https://user-images.githubusercontent.com/17251607/231466938-9cdb70b1-631c-4201-998c-6743ade908c0.PNG) I first thought that _Project-B_ has some different configuration but then I removed all the created links for _Project-A_ by running `npm unlink --no-save common.ui` and tried to re-add them once again but this time it didn't work. I could only see the _Common_ project linked without its 3rd party libraries. Do you know why could that be the case? Am I missing something? Is there something I should do before linking a project?
关闭于 2023-10-12 1 条评论