Given 2 repos:
/twreporter-react
/node_modules
/@twreporter
/redux # scoped package @twreporter/redux
/redux
/src
/server.js
/twreporter-npm-packages
/packages
/redux # the source code of @twreporter/redux
/node_modules
/lib
/create-store.js
We want to develop @twreporter/redux
and test it being used in twreporter-react
at local.
Use npm link
or yarn link
to symlink the files of a module into the consumers node_modules
folder.
This is the most common suggested way.
But it has some problems:
-
Not like packages published with
npm publish
will only contain the files we specified. When compiling the files in@twreporter/redux
, the compiler like Babel may take the closest config file (.babelrc
) relative to the target. -
The
require
invoked in the@twreporter/redux
will search the Node modules in/twreporter-npm-packages/packages/redux/node_modules
, nottwreporter-react/node_modules
.
As mentioned in this PR comment, we can use npm pack
or yarn pack
to pack the package.
Ref:
As mentioned in this PR comment, we can use package like yalc
to simulate a local npm registry.
Ref: