I have three local npm packages: C:\projects\A
, C:\projects\B
and C:\projects\main
. Main
is a React application built with Webpack. Main
depends on A
and B
, also A
depends on B
We have our own βglobalβ package manager, which ensures that packages are located in the same parent folder.
I want to take this into account:
I did this in Main
package.json
:
.... "dependencies": { "A": "file:../A", "B": "file:../B", "react": ... .........
But I ran into an incomprehensible problem: npm
does not install all packages in A
and B
node_modules, so Webpack build fails. And I need to run npm install
every time.
I googled and found linklocal which replaces all local packages as symbolic links. But ran into another problem:
linklocal does not set dependency dependencies, so you usually set dependency dependencies twice: once during npm installation, then again after linklocal
So, I ran linklocal
and then npm install
again in the postinstall
script. But npm @ 3 did nothing with symbolic folders:
npm WARN update-linked node_modules/A needs updating to 1.0.0 from 1.0.0 but we can't, as it a symlink
Then I decided to change postinstall
to go to each symbolically connected module and run npm install
from there. And it worked at first glance: the installation went well, and also bundled with webpack. But Webpack started linking two copies of React (which is forbidden).
How to configure my packages?