Allow local project to depend on local lerna packages

You should be able to accomplish this with npm link. Although I have not tried this using a local dependency that is not published on npm.

Directory tree

foo/
  packages/
    core/
      package.json
    errors/
      package.json
bar/
    package.json

foo/packages/core/package.json

{
  ...
  dependencies: {
    "@foo/errors": "*"
  }
}

bar/package.json

{
  ...
  dependencies: {
    "@foo/core": "../foo/packages/core"
  }
}

Run the following commands

cd foo
npx lerna clean
npx lerna bootstrap --hoist
npm run build # command to build your projects
cd packages/core
npm link
cd ../../../bar
npm i
npm link @foo/core

Removing package-lock.json files usually does more harm then good! And about not being able to find @foo/errors, if you ran npm bootstrap, @foo/core should be symlinked to @foo/errors. One possibility could be that your lerna scripts are using npm while you where running install/link with yarn.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)