I got a big project that is a monorepo consisting of multiple scripts and libraries, its structure is the following:
package.json // "private":true
\packages
\comp1
\package.json // an actual component
\comp2
\package.json // an actual component
\comp3
\package.json // an actual component
I've made a monorepo.tgz
using yarn pack
.
Then I made a test app whose package.json
look like this:
"scripts": {
// this is a script in one of the monorepo's components
"start": "ui-build --bundle --watch -p 3000"
}
"dependencies": {
"comp1": "../monorepo/monorepo.tgz",
"comp2": "../monorepo/monorepo.tgz",
"comp3": "../monorepo/monorepo.tgz",
...
but its not working, when I run start
its complaining that ui-build: command not found
.
How can I test this monorepo locally to simulate a published npm package as closely as possible?
Using npm link
(or yarn link
), you can 'install' the packages from your local development environment.
To do this, you first run npm link
in the directory of the package you want to install, so in \packages\comp1
. Then in your testapp, run npm link comp1
. This will install your package. Repeat for any others you want to install.
More info: https://docs.npmjs.com/cli/v6/commands/npm-link https://classic.yarnpkg.com/en/docs/cli/link/