lerna

Lerna fails with 404 when trying to link dependency


My structure is as follows:

Neither project is published to npm yet.

When I run lerna boostrap I get:

❯ lerna bootstrap
lerna info version 2.4.0
lerna info versioning independent
lerna info Bootstrapping 2 packages
lerna info lifecycle preinstall
lerna info Installing external dependencies
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: npm install
lerna ERR! npm ERR! code E404
lerna ERR! npm ERR! 404 Not Found: myproj-util@*

My understanding from the docs is that when running lerna bootstrap it should "check if each dependency is part of the Lerna repo" so it should just be symlinked.

So... why is it not just symlinking my internal dependency? The dependency is under packages/ and the folder name and package name match exactly.


Solution

  • This line from the docs provides a hint:

    The version of babel-generator in the package.json of babel-core is satisfied by packages/babel-generator, passing for an internal dependency.

    i.e., your internal packages have to match any version constraints otherwise they will be treated as external packages.

    Even though my dependency was on "myproj-util": "*", I had forgotten to add a version (any version) to the package.json of myproj-util. Simply adding the version fixed the problem. i.e., the myproj-util package.json looks like:

    {
      "name": "myproj-util",
      "version": "0.1.0"
    }