Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn install --production installs some dev packages #2703

Closed
janaz opened this issue Feb 16, 2017 · 4 comments
Closed

yarn install --production installs some dev packages #2703

janaz opened this issue Feb 16, 2017 · 4 comments

Comments

@janaz
Copy link

janaz commented Feb 16, 2017

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

bug

What is the current behavior?

yarn install --production installs some of the packages from devDependencies into node_modules directory

If the current behavior is a bug, please provide the steps to reproduce.

package.json

{
  "name": "test",
  "version": "1.0.0",
  "dependencies": {
    "lodash": "4.17.4"
  },
  "devDependencies": {
    "chai": "3.5.0",
    "nock": "9.0.6"
  }
}

To reproduce, please create the package.json file with the above content and run:

$ yarn install --production

What is the expected behavior?

Expected behavior - node_modules doesn't contain the chai module:

$ yarn install --production
$ ls -1 node_modules/ | grep chai
chai # this line should not be printed

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

My environment: OSX 10.11.6

$ uname -a
Darwin tomasz 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep  1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64
$ yarn --version
0.20.3
node --version
v7.5.0
npm --version
4.1.2
@janaz
Copy link
Author

janaz commented Feb 26, 2017

Here are some additional details after debugging the code:

The ignorePatterns list is populated correctly with [chai@3.5.0, nock@9.0.6]

The markIgnored function is trying to calculate the total number of requests to the pattern. If there's more than 1 request the package will not be ignored.

When markIgnored is executed for chai@3.5.0 the ref.requests array is:

  requests:
   [ PackageRequest {
       parentRequest: undefined,
       lockfile: [Object],
       registry: 'npm',
       reporter: undefined,
       resolver: [Object],
       optional: false,
       pattern: 'chai@3.5.0',
       config: [Object] },
     PackageRequest {
       parentRequest: [Object],
       lockfile: [Object],
       registry: 'npm',
       reporter: undefined,
       resolver: [Object],
       optional: false,
       pattern: 'chai@>=1.9.2 <4.0.0',
       config: [Object] } ],

The first element of the array represents the module specified in devDependecies setion of my package.json file. The second element represents the module specified in dependencies section of the nock module which in my package.json is also defined in the devDependencies section and should be ignored.

The problem is that at this point we don't check if the requests (PackageRequest objects) are coming from other ignored packages or not.

@janaz
Copy link
Author

janaz commented Feb 26, 2017

To summarize, the issue happens when

(1) in our package.json we define:

"dependencies": {
  "A": "0.0.1"
},
"devDependencies": {
  "B": "0.0.1",
  "C": "0.0.1"
}

(2) The package.json of the module C is:

"dependencies": {
  "B": "0.0.1"
}

then:

yarn install --production

will install package B (+its dependecies)

@scinos
Copy link

scinos commented Mar 2, 2017

Dupe of #2304 ?

@janaz
Copy link
Author

janaz commented Mar 2, 2017

It is in fact the same issue as #2304. This one includes the in-depth analysis of the problem. I will close it and put some comments in the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants