Jeffpowrs
Jeffpowrs

Reputation: 4560

Lerna add will not add internal dependencies

I'm using lerna to manage a React component library. Some of my components have both external dependencies from the npm registry as well as internal dependencies, sibling packages in the repository.

Directory structure

I'm attempting to add internal dependencies to another package using the lerna add command. Specifically I want to add Utils, Typography, Link, to HRWrapper.

To add Utils I run:

lerna add Utils --scope=HRWrapper

and receive this error:

lerna notice cli v3.2.1
lerna info versioning independent
lerna WARN No packages found where Utils can be added.

To install Typography I run:

lerna add Typography --scope=HRWrapper

and receive this error:

lerna notice cli v3.2.1
lerna info versioning independent
lerna ERR! Error: 404 Not Found - GET https://registry.npmjs.org/Typography - Not found
lerna ERR!     at res.buffer.catch.then.body (/Users/powje6f/sites/vz-react/node_modules/npm-registry-fetch/check-response.js:104:15)
lerna ERR! lerna 404 Not Found - GET https://registry.npmjs.org/Typography - Not found

I'm not sure what the first error means when trying to install Utils. But, for some reason when I try to add Typography it's searching for it in the npm registry.

Here is my lerna.json:

{
  "lerna": "2.10.0",
  "packages": ["packages/**/*"],
  "version": "independent"
}

What am I doing wrong?

Upvotes: 3

Views: 3047

Answers (1)

Zhansingsong
Zhansingsong

Reputation: 322

I also run across the similar trouble. you can try this:

lerna add module-1 packages/prefix-*       Adds the module-1 package to the packages in the 'prefix-' prefixed folders
// Utils
lerna add Utils packages/HRWrapper

// Typography
lerna add Typography packages/HRWrapper

this way is working for me.

lerna add module-1 --scope=module-2 

I guess the reason why not work normally is:

Only if module-1 already was registered on NPM, it is available.

Upvotes: 5

Related Questions