yarnpkg/yarn

`yarn add` with workspaces doesn't install to workspace root

Open

#4,513 opened on Sep 21, 2017

View on GitHub
 (13 comments) (12 reactions) (1 assignee)JavaScript (41,514 stars) (2,731 forks)batch import
cat-bughelp wantedhigh-prioritytriaged

Description

Do you want to request a feature or report a bug? bug

What is the current behavior? Running yarn add foo inside a workspace directory does two unexpected things;

  1. it installs the newly added dependency in /my-workspace/node_modules/foo, whereas I would expect it to install it to the workspace root, e.g.: /node_modules/foo
  2. it installs all other dependencies of my-workspace to /my-workspace/node_modules

If the current behavior is a bug, please provide the steps to reproduce. See also: https://github.com/edorivai/workspace-test

  1. Create an empty directory(workspace-1), and add a minimal package.json file.
  2. In root package.json, set "workspaces": [ "./*" ]
  3. Run:
cd workspace-1
yarn add lodash.assign
  1. By now, I'd have (also see screenshot)
/workspace-1
  /node_modules
    /lodash.assign

What is the expected behavior? I would have expected

/node_modules
  /lodash.assign
/workspace-1

With node modules being installed at the root level.

Please mention your node.js, yarn and operating system version.

$ uname -srvo
Linux 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 GNU/Linux

$ lsb_release -rcd
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

$ node --version
v8.5.0

$ npm --version
5.3.0

$ yarn --version
1.0.2-20170921.1145

Contributor guide