Lerna: Can't link local lerna module to another local project

Created on 10 May 2019  路  2Comments  路  Source: lerna/lerna

Here's how my setup looks like;

modules/
  lerna.json
  package.json
  packages/
    module-a/
      package.json
    module-b/
      package.json
    module-ab/ # depends on module-a & module-b
      package.json

another-project/ # needs module-ab
  index.js
  package.json

I am working on module-a, module-b, module-ab and another-project locally.

I want to use module-ab in another-project locally without publishing it to npm. Since, I am modifying all four packages locally, I want to npm link module-ab to another-project. So when I run npm link in module-ab, it throws an error saying;

npm ERR! code ETARGET
npm ERR! notarget No matching version found for module-a@^0.2.1-alpha.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'module-ab'
npm ERR! notarget

Is there any way I can use module-ab in another-package locally? I cannot move another-package to modules/packages.

lerna.json


{
  "npmClient": "npm",
  "packages": [
    "packages/*"
  ],
  "version": "0.2.1-alpha.0"
}

Your Environment

| Executable | Version |
| ---: | :--- |
| lerna --version | 3.13.3 |
| npm --version | 6.4.1 |
| yarn --version | N/A |
| node --version | v8.12.0 |

| OS | Version |
| ---: | :--- |
| macOS Mojave | 10.14.4 |

Most helpful comment

My bad. This just works 馃槄

# in another-package
npm i ../modules/packages/module-ab

All 2 comments

My bad. This just works 馃槄

# in another-package
npm i ../modules/packages/module-ab

npm link will print out the path that you can use in your another-project to do npm link <path>

Was this page helpful?
0 / 5 - 0 ratings