Lerna bootstrap does not link local dependencies
envgap__lerna__lerna-2352
Original GitHub issue ↗Opened 2019-11-18
01 / FAILURE SIGNATURE
As reported upstream
> Cannot find module 'module-a' from 'import.test.js'
Not a benchmark task.
- No curated issue-specific recipe or verified environment fix is available.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
package.json- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
lerna/lerna #2352 · read the original issue
<!--- Provide a general summary of the issue in the Title above -->
I have configured two modules in a mono repo to use lerna with a local dependency. I expected that
```bash
$ lerna bootstrap
$ lerna run test
```
would be sufficient to download all external dependencies, link a local dependency and execute and pass all tests in all modules.
## Expected Behavior
As per the [lerna bootstrap](https://github.com/lerna/lerna/tree/master/commands/bootstrap#usage) documentation:
> 2. Symlink together all Lerna packages that are dependencies of each other.
Thus, I expected that `lerna bootstrap` would create a symlink in `module-b/node_modules` below that points to `module-a` (which then would allow the tests to be executed and pass).
## Current Behavior
No linking occurs, which cause the tests to fail:
> lerna ERR! yarn run test exited 1 in 'module-b'
> lerna ERR! yarn run test stdout:
> yarn run v1.19.1
> $ jest
> info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
>
> lerna ERR! yarn run test stderr:
> FAIL ./import.test.js
> ● Test suite failed to run
>
> Cannot find module 'module-a' from 'import.test.js'
>
> > 1 | const moduleA = require('module-a');
> | ^
> 2 |
> 3 | test('should import module-a', () => {
> 4 | moduleA();
>
> at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
> at Object.<anonymous> (import.test.js:1:1)
>
## Steps to Reproduce
1. Create the folder structure below
2. Copy the files inlined to their corresponding directory
3. Execute `$ lerna bootstrap` followed by `$ lerna run test`
```
project-root
+ packages
| + module-a
| | + package.json
| | + index.js
| |
| + module-b
| | + package.json
| | + import.test.js
|
+ lerna.json
```
<details><summary>packages/module-a/package.json</summary><p>
<!-- browsers demand the next line be empty -->
```json
{
"name": "module-a",
"version": "1.0.0",
"private": true,
"main": "index.js",
"scripts": {
"test": "echo \"Test passed in module-a\""
}
}
```
</p></details>
<details><summary>packages/module-a/index.js</summary><p>
<!-- browsers demand the next line be empty -->
```javascript
module.exports = () => console.log('Log in module-a');
```
</p></details>
<details><summary>packages/module-b/package.json</summary><p>
<!-- browsers demand the next line be empty -->
```json
{
"name": "module-b",
"version": "1.0.0",
"private": true,
"main": "index.js",
"scripts": {
"test": "jest"
},
"dependencies": {
"module-a": "file:../module-a"
},
"devDependencies": {
"jest": "^24.9.0"
}
}
```
</p></details>
<details><summary>packages/module-b/import.test.js</summary><p>
<!-- browsers demand the next line be empty -->
```javascr04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
Issue-specific recipe and runtime smoke command require review against the complete issue and repository.
Legacy already_works is install-only; proposed control still requires runtime verification.