question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can not add local package

See original GitHub issue

Expected Behavior

when i run

 lerna add module-0 --scope=module-1

it should link to module-1

Current Behavior

but npm is output error message, it tell me

lerna notice cli v3.13.1
lerna info filter [ 'module-1' ]
lerna info Adding module-0 in 1 package
lerna notice filter including "module-1"
lerna info filter [ 'module-1' ]
lerna WARN bootstrap Installing local packages that do not match filters from registry
lerna info Bootstrapping 1 package
lerna info Installing external dependencies
lerna ERR! npm install --no-save exited 1 in 'module-1'
lerna ERR! npm install --no-save stderr:
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for module-0

but when i run

 lerna add module-0

it linked others successfully

lerna.json

{
  "packages": [
    "packages/*"
  ],
  "version": "1.0.0"
}

module-0/package.json

{
  "name": "module-0",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

module-1/package.json

{
  "name": "module-1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "module-0": "1.0.0"
  }
}

file tree

β”œβ”€β”€ lerna.json
β”œβ”€β”€ package.json
└── packages
    β”œβ”€β”€ module-0
    β”‚Β Β  β”œβ”€β”€ index.js
    β”‚Β Β  └── package.json
    β”œβ”€β”€ module-1
    β”‚Β Β  β”œβ”€β”€ index.js
    β”‚Β Β  └── package.json
    └── module-2
        β”œβ”€β”€ index.js
        └── package.json

Your Environment

Executable Version
lerna --version 3.13.1
npm --version 6.4.1
node --version 8.12.0
OS Version
macOS Sierra 10.12.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

23reactions
hilleercommented, Oct 8, 2019

I am sorry, but I still think this issue applies. Or at least additional descriptions in documentation would be nice…

If I am pointing to a local package bar in a package foo like:

dependencies: {
    "bar": "file:../bar"
}

and I run lerna bootstrap it will not install bar in node_modules of foo.

However, if I run lerna bootstrap --scope foo it will install the local dependency as expected.

If I use the lerna add bar --scope=foo to add it, it will add the dependency like this(as if it was installed remotely from the npm registry):

dependencies: {
   "bar": "^1.0.0"
}

and it will work as expected.

As someone already pointed out, I really find a lack of documentation here - it was really hard to figure out how to do it properly and know that Lerna was actually symlinking and using the local package.

I’d gladly contribute and add a PR for update documentation, but I am still not entirely sure I get how it works so…

5reactions
Christian24commented, Mar 31, 2019

@luponZ I can confirm your solution works, however, I would like to know why. From my understanding it should also work with --scope. Maybe this should be reopened because it is a bug?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import local packages in go? - Stack Overflow
Well, I figured out the problem. Basically Go starting path for import is $HOME/go/src. So I just needed to add myapp in front...
Read more >
Import Local Swift Package in Xcode 13.3 - Apple Developer
In the file list on the left, right-clicked on "Packages" -> "Add Packages ..." -> "Add Local" and selected the root directory of...
Read more >
How to add local Swift Package as dependency?
The proper way to add a local Swift Package is via menu in Xcode: Swift Packages -> Add Package Dependency... And type the...
Read more >
How to add local Swift Packages to an iOS project
Learn how to add local dependencies to your iOS project by using the Swift Package Manager and Xcode.
Read more >
Golang Import Local Package - Linux Hint
Since we do not have any external packages, the file contains the module name and the go version. Golang Create Package. As mentioned,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found