yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.38k stars 2.72k forks source link

Mixing workspaces and modules-folder creates some node_modules directories #5449

Open Moghul opened 6 years ago

Moghul commented 6 years ago

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

Bug What is the current behavior? I run yarn install with a custom modules-folder setting in .yarnrc and it creates the custom folder, but it also creates node_modules in various places. If the current behavior is a bug, please provide the steps to reproduce.

The hierarchy is as follows:

Project
    statistics/
        .yarnrc
        package.json
    template/
        .yarnrc
        package.json
    webpack-config/
        .yarnrc
        package.json
    .yarnrc
    package.json
    yarn.lock

All .yarnrc looks like this, with the idea being that it adds dependencies to Project/vendor first, and then workspace/vendor if it's necessary.

--*.modules-folder vendor
--remove.modules-folder vendor

Project/package.json looks like this:

{
  "name": "Scripts",
  "version": "1.0.0",
  "private": true,
  "workspaces": ["statistics", "templates", "webpack-config"]
}

Project/statistics/package.json:

{
  "name": "statistics",
  "version": "1.0.0",
  "dependencies": {
    "@uirouter/angularjs": "1.0.4",
    "angular": "1.6.4",
    "angular-ui-bootstrap": "2.5.0",
    "angular-xeditable": "0.8.0",
    "chart.js": "2.6.0",
    "checklist-model": "0.11.0",
    "tc-angular-chartjs": "2.1.4"
  }
}

Project/templates/package.json

{
  "name": "templates",
  "version": "1.0.0",
  "dependencies": {
    "angular": "1.6.4",
    "bootstrap-select": "1.12.2",
    "bootstrap-slider": "9.7.2",
    "knockout": "3.4.1",
    "ng-file-upload": "12.2.13",
    "requirejs": "2.3.5",
    "requirejs-text": "2.0.12",
    "tc-angular-chartjs": "2.1.4"
  }
}

Project/webpack-config/package.json

{
  "name": "webpack-config",
  "version": "1.0.0",
  "dependencies": {
    "css-loader": "^0.28.9",
    "extract-text-webpack-plugin": "4.0.0-alpha.0",
    "file-loader": "^1.1.8",
    "script-template-loader": "^1.0.3",
    "style-loader": "^0.20.2",
    "uglifyjs-webpack-plugin": "^1.2.0",
    "webpack-cleanup-plugin": "^0.5.1",
    "webpack-file-changer": "^2.0.1"
  }
}

Result of yarn install:

Project
    node_modules/
        .bin/
            browserslist
            cssesc
            csso
            errno
            esparse
            esvalidate
            js-yaml
            jsesc
            json5
            mkdirp
            r.js
            r_js
            regjsparser
            rimraf
            svgo
            uglifyjs
    statistics/
        .yarnrc
        package.json
    templates/
        node_modules
            .bin/
                r.js
                r_js
        .yarnrc
        package.json
    vendor/
        various packages/
    webpack-config/
        .yarnrc
        package.json
    .yarnrc
    package.json
    yarn.lock

All the files in node_modules/.bin/ are symlinks to .js files.

EDIT: Forgot to mention. This also seems to break some references. For example, webpack can't find source-map even though it's in Project/vendor/ and I look there for dependencies. Note that source-map is a dependency of a dependency.

What is the expected behavior? All dependencies are bundled in directories named after modules-folder and no node_modules directories are created.

Please mention your node.js, yarn and operating system version. Node 9.4.0 Yarn 1.5.1 Ubuntu 16.04

Moghul commented 6 years ago

Of course, if I'm doing something wrong and have misunderstood the documentation, please let me know.