← All tasks
javascriptyarnpkg/berry #652Not a task: not reproduced

[Bug] yarn add --peer after --dev doesn't add peer dependency

envgap__yarnpkg__berry-652

Original GitHub issue ↗Opened 2019-12-28

01 / FAILURE SIGNATURE

As reported upstream

My tests will complain about: `Cannot find module 'rxjs' from '...'`
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

yarnpkg/berry #652 · read the original issue
- [ ] I'd be willing to implement a fix



**Describe the bug**



I have a library that depends on `rxjs` as a peer dependency, but it also has tests inside it. 



If I add `rxjs` as a normal dependency, tests run properly. If instead I run:



`yarn add --peer --dev rxjs`



My tests will complain about: `Cannot find module 'rxjs' from '...'`



Note that I'm also using typescript and `ts-jest`. 



Ideally, the dependency should be available to both peer and dev dependencies.



**To Reproduce**



```js repro

const {promises: {readFile}} = require(`fs`);



await packageJsonAndInstall({

  devDependencies: {},

});



await yarn(`add`, `--dev`, `rxjs`);

await yarn(`add`, `--peer`, `rxjs`);



const pkgJson = JSON.parse(await readFile(`package.json`, `utf8`));

expect(pkgJson).toHaveProperty(`peerDependencies`);

expect(pkgJson).toHaveProperty(`devDependencies`);

expect(pkgJson.peerDependencies).toHaveProperty(`rxjs`);

expect(pkgJson.devDependencies).toHaveProperty(`rxjs`);

```



**Additional context**



This is also a bug in yarn v1: https://github.com/yarnpkg/yarn/issues/5287

Continue on GitHub ↗

04 / 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 reproduction is generic install-only; match the actual issue failure before admission.