Skip to content

[Bug] yarn add dep & devDep duplicate the dependency. #361

@CallMeLaNN

Description

@CallMeLaNN

Describe the bug

Sometime I forgot to add --dev when trying to add devDependencies. Doing so again will duplicate the dependency entry in package.json.

IMO, v1 will stop us and ask to remove the package first. For v2, we can just automatically move it.

To Reproduce

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

await packageJsonAndInstall({
  devDependencies: {lodash: `*`},
});

await yarn(`add`, `lodash`);

const pkgJson = JSON.parse(await readFile(`package.json`, `utf8`));
expect(pkgJson.dependencies).not.toHaveProperty(`lodash`);

Environment if relevant (please complete the following information):

  • OS: OSX
  • Node version: 10.16.2
  • Yarn version: 2.0.0-rc1 (tag 2019-08-16)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededreproducibleThis issue can be successfully reproduced

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions