-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
does not remove extraneous nested node_modules
folders
#8146
Labels
fixed-in-modern
This issue has been fixed / implemented in Yarn 2+.
Comments
chancancode
added a commit
to emberjs/ember.js
that referenced
this issue
May 21, 2020
Closing as fixed in v2 where the node_modules linker has been greatly improved |
devversion
added a commit
to devversion/dev-infra
that referenced
this issue
Oct 16, 2021
…n Bazel This commit fixes an issue where old modules from other version branches are preserved in the `node_modules` of a newly checked-out version branch. Old/extraneous modules can cause the Bazel NodeJS rules to throw with an error when preparing the `@npm//` workspace. Yarn v1 has a bug where nested node modules are not cleaned properly. Yarn v2+ supposedly fixes that, but for now we are still on v1.x and in general it seems more safe to clean the node modules. Here is the related Yarn bug: yarnpkg/yarn#8146. Here is an example Bazel NodeJS error: ``` ✓ Created pull request #23758 in angular/components. ✓ Release staging pull request has been created. Please ask team members to review: angular/components#23758. ⠋ Waiting for pull request #23758 to be merged. ✓ Pull request #23758 has been merged. [1/5] Validating package.json... [2/5] Resolving packages... warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "typescript@^3.2.2" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" [3/5] Fetching packages... [4/5] Linking dependencies... warning "@angular/bazel > [email protected]" has incorrect peer dependency "typescript@~3.8.2". warning " > @bazel/[email protected]" has unmet peer dependency "karma-junit-reporter@>=2.0.0". warning " > [email protected]" has incorrect peer dependency "typescript@~3.9.5". [5/5] Building fresh packages... $ node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js patching file node_modules/@angular/compiler/bundles/compiler.umd.js Hunk #1 succeeded at 26295 (offset 5289 lines). Hunk #2 succeeded at 26319 (offset 5289 lines). Hunk #3 succeeded at 26330 (offset 5289 lines). patching file node_modules/@bazel/typescript/internal/build_defs.bzl Hunk #1 succeeded at 123 with fuzz 1 (offset 21 lines). Hunk #2 succeeded at 141 with fuzz 1 (offset 21 lines). Hunk #3 succeeded at 178 (offset 20 lines). Hunk #4 succeeded at 201 (offset 20 lines). Hunk #5 succeeded at 217 (offset 21 lines). patching file node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js Hunk #1 succeeded at 396 (offset 15 lines). Patching file /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_package/packager.js with 2 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/metadata/bundle_index_host.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/ngtsc/entry_point/src/logic.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/transformers/compiler_host.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ngc-wrapped/index.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_module.bzl with 4 edits.. Compiling @angular/core : module as esm2015 Compiling @angular/animations : module as esm2015 Compiling @angular/compiler/testing : module as esm2015 Compiling @angular/animations : main as umd Compiling @angular/compiler/testing : main as umd Compiling @angular/core/testing : module as esm2015 Compiling @angular/animations/browser : module as esm2015 Compiling @angular/common : module as esm2015 Compiling @angular/core : main as umd Compiling @angular/platform-browser : module as esm2015 Compiling @angular/common/http : module as esm2015 Compiling @angular/common/testing : module as esm2015 Compiling @angular/platform-browser-dynamic : module as esm2015 Compiling @angular/platform-browser/testing : module as esm2015 Compiling @angular/platform-browser/animations : module as esm2015 Compiling @angular/router : module as esm2015 Compiling @angular/platform-browser-dynamic/testing : module as esm2015 Compiling @angular/platform-server : module as esm2015 Compiling @angular/animations/browser/testing : module as esm2015 Compiling @angular/common/http/testing : module as esm2015 Compiling @angular/forms : module as esm2015 Compiling @angular/platform-server/init : module as esm2015 Compiling @angular/platform-server/testing : module as esm2015 Compiling @angular/router/testing : module as esm2015 Compiling @angular/animations/browser/testing : main as umd Compiling @angular/animations/browser : main as umd Compiling @angular/common/http : main as umd Compiling @angular/common : main as umd Compiling @angular/common/http/testing : main as umd Compiling @angular/forms : main as umd Compiling @angular/platform-browser : main as umd Compiling @angular/platform-server/init : main as umd Compiling @angular/core/testing : main as umd Compiling @angular/platform-browser-dynamic : main as umd Compiling @angular/platform-browser/testing : main as umd Compiling @angular/platform-browser-dynamic/testing : main as umd Compiling @angular/platform-browser/animations : main as umd Compiling @angular/platform-server : main as umd Compiling @angular/platform-server/testing : main as umd Compiling @angular/common/testing : main as umd Compiling @angular/router/testing : main as umd Compiling @angular/router : main as umd $ husky install husky - Git hooks installed ✓ Installed project dependencies. ⠋ Building release output. Building release packages... Compiling with Ivy: false Starting local Bazel server and connecting to it... Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded [1/5] Validating package.json... [2/5] Resolving packages... warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "typescript@^3.2.2" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" Loading: 0 packages loaded success Already up-to-date. $ node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js Patch: /Users/andrewjs/git/components/tools/postinstall/flat_module_factory_resolution.patch has been applied already. Skipping.. Patch: /Users/andrewjs/git/components/tools/postinstall/manifest_externs_hermeticity.patch has been applied already. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_package/packager.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/metadata/bundle_index_host.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/ngtsc/entry_point/src/logic.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/transformers/compiler_host.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ngc-wrapped/index.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_module.bzl is already patched. Skipping.. $ husky install husky - Git hooks installed Loading: 0 packages loaded could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' INFO: Repository npm instantiated at: /Users/andrewjs/git/components/WORKSPACE:51:13: in <toplevel> /private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/index.bzl:83:18: in yarn_install Repository rule yarn_install defined at: /private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:795:31: in <toplevel> Loading: 0 packages loaded ERROR: An error occurred during the fetch of repository 'npm': Traceback (most recent call last): File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 793, column 24, in _yarn_install_impl _create_build_files(repository_ctx, "yarn_install", node, repository_ctx.attr.yarn_lock, repository_ctx.attr.generate_local_modules_build_files) File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 425, column 13, in _create_build_files fail("generate_build_file.ts failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr)) Error in fail: generate_build_file.ts failed: STDOUT: STDERR: could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' ERROR: Error fetching repository: Traceback (most recent call last): File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 793, column 24, in _yarn_install_impl _create_build_files(repository_ctx, "yarn_install", node, repository_ctx.attr.yarn_lock, repository_ctx.attr.generate_local_modules_build_files) File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 425, column 13, in _create_build_files fail("generate_build_file.ts failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr)) Error in fail: generate_build_file.ts failed: STDOUT: STDERR: could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' ERROR: no such package '@npm//@bazel/protractor': generate_build_file.ts failed: STDOUT: STDERR: could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' Loading: 0 packages loaded Loading: 0 packages loaded (node:14775) UnhandledPromiseRejectionWarning: Error: Command failed: bazel query --output=label "attr('tags', '\[.*release-package.*\]', //src/...) intersect kind('.*_package', //src/...)" at checkExecSyncError (child_process.js:760:11) at Object.execSync (child_process.js:833:15) at exec (/Users/andrewjs/git/components/scripts/build-packages-dist.ts:139:18) at buildReleasePackages (/Users/andrewjs/git/components/scripts/build-packages-dist.ts:72:19) at performNpmReleaseBuild (/Users/andrewjs/git/components/scripts/build-packages-dist.ts:48:10) at /Users/andrewjs/git/components/.ng-dev/release.ts:96:12 at Generator.next (<anonymous>) at fulfilled (/Users/andrewjs/git/components/.ng-dev/release.ts:5:58) (Use `node --trace-warnings ...` to show where the warning was created) (node:14775) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:14775) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ✘ Could not build release output. Please check output above. ```
josephperrott
pushed a commit
to angular/dev-infra
that referenced
this issue
Oct 19, 2021
…n Bazel (#271) This commit fixes an issue where old modules from other version branches are preserved in the `node_modules` of a newly checked-out version branch. Old/extraneous modules can cause the Bazel NodeJS rules to throw with an error when preparing the `@npm//` workspace. Yarn v1 has a bug where nested node modules are not cleaned properly. Yarn v2+ supposedly fixes that, but for now we are still on v1.x and in general it seems more safe to clean the node modules. Here is the related Yarn bug: yarnpkg/yarn#8146. Here is an example Bazel NodeJS error: ``` ✓ Created pull request #23758 in angular/components. ✓ Release staging pull request has been created. Please ask team members to review: angular/components#23758. ⠋ Waiting for pull request #23758 to be merged. ✓ Pull request #23758 has been merged. [1/5] Validating package.json... [2/5] Resolving packages... warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "typescript@^3.2.2" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" [3/5] Fetching packages... [4/5] Linking dependencies... warning "@angular/bazel > [email protected]" has incorrect peer dependency "typescript@~3.8.2". warning " > @bazel/[email protected]" has unmet peer dependency "karma-junit-reporter@>=2.0.0". warning " > [email protected]" has incorrect peer dependency "typescript@~3.9.5". [5/5] Building fresh packages... $ node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js patching file node_modules/@angular/compiler/bundles/compiler.umd.js Hunk #1 succeeded at 26295 (offset 5289 lines). Hunk #2 succeeded at 26319 (offset 5289 lines). Hunk #3 succeeded at 26330 (offset 5289 lines). patching file node_modules/@bazel/typescript/internal/build_defs.bzl Hunk #1 succeeded at 123 with fuzz 1 (offset 21 lines). Hunk #2 succeeded at 141 with fuzz 1 (offset 21 lines). Hunk #3 succeeded at 178 (offset 20 lines). Hunk #4 succeeded at 201 (offset 20 lines). Hunk #5 succeeded at 217 (offset 21 lines). patching file node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js Hunk #1 succeeded at 396 (offset 15 lines). Patching file /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_package/packager.js with 2 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/metadata/bundle_index_host.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/ngtsc/entry_point/src/logic.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/transformers/compiler_host.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ngc-wrapped/index.js with 1 edits.. Patching file /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_module.bzl with 4 edits.. Compiling @angular/core : module as esm2015 Compiling @angular/animations : module as esm2015 Compiling @angular/compiler/testing : module as esm2015 Compiling @angular/animations : main as umd Compiling @angular/compiler/testing : main as umd Compiling @angular/core/testing : module as esm2015 Compiling @angular/animations/browser : module as esm2015 Compiling @angular/common : module as esm2015 Compiling @angular/core : main as umd Compiling @angular/platform-browser : module as esm2015 Compiling @angular/common/http : module as esm2015 Compiling @angular/common/testing : module as esm2015 Compiling @angular/platform-browser-dynamic : module as esm2015 Compiling @angular/platform-browser/testing : module as esm2015 Compiling @angular/platform-browser/animations : module as esm2015 Compiling @angular/router : module as esm2015 Compiling @angular/platform-browser-dynamic/testing : module as esm2015 Compiling @angular/platform-server : module as esm2015 Compiling @angular/animations/browser/testing : module as esm2015 Compiling @angular/common/http/testing : module as esm2015 Compiling @angular/forms : module as esm2015 Compiling @angular/platform-server/init : module as esm2015 Compiling @angular/platform-server/testing : module as esm2015 Compiling @angular/router/testing : module as esm2015 Compiling @angular/animations/browser/testing : main as umd Compiling @angular/animations/browser : main as umd Compiling @angular/common/http : main as umd Compiling @angular/common : main as umd Compiling @angular/common/http/testing : main as umd Compiling @angular/forms : main as umd Compiling @angular/platform-browser : main as umd Compiling @angular/platform-server/init : main as umd Compiling @angular/core/testing : main as umd Compiling @angular/platform-browser-dynamic : main as umd Compiling @angular/platform-browser/testing : main as umd Compiling @angular/platform-browser-dynamic/testing : main as umd Compiling @angular/platform-browser/animations : main as umd Compiling @angular/platform-server : main as umd Compiling @angular/platform-server/testing : main as umd Compiling @angular/common/testing : main as umd Compiling @angular/router/testing : main as umd Compiling @angular/router : main as umd $ husky install husky - Git hooks installed ✓ Installed project dependencies. ⠋ Building release output. Building release packages... Compiling with Ivy: false Starting local Bazel server and connecting to it... Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded [1/5] Validating package.json... [2/5] Resolving packages... warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "typescript@^3.2.2" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^2.2.1" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" warning Resolution field "[email protected]" is incompatible with requested version "https-proxy-agent@^4.0.0" Loading: 0 packages loaded success Already up-to-date. $ node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js Patch: /Users/andrewjs/git/components/tools/postinstall/flat_module_factory_resolution.patch has been applied already. Skipping.. Patch: /Users/andrewjs/git/components/tools/postinstall/manifest_externs_hermeticity.patch has been applied already. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_package/packager.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/metadata/bundle_index_host.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/ngtsc/entry_point/src/logic.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/compiler-cli/src/transformers/compiler_host.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ngc-wrapped/index.js is already patched. Skipping.. File /Users/andrewjs/git/components/node_modules/@angular/bazel/src/ng_module.bzl is already patched. Skipping.. $ husky install husky - Git hooks installed Loading: 0 packages loaded could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' INFO: Repository npm instantiated at: /Users/andrewjs/git/components/WORKSPACE:51:13: in <toplevel> /private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/index.bzl:83:18: in yarn_install Repository rule yarn_install defined at: /private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:795:31: in <toplevel> Loading: 0 packages loaded ERROR: An error occurred during the fetch of repository 'npm': Traceback (most recent call last): File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 793, column 24, in _yarn_install_impl _create_build_files(repository_ctx, "yarn_install", node, repository_ctx.attr.yarn_lock, repository_ctx.attr.generate_local_modules_build_files) File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 425, column 13, in _create_build_files fail("generate_build_file.ts failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr)) Error in fail: generate_build_file.ts failed: STDOUT: STDERR: could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' ERROR: Error fetching repository: Traceback (most recent call last): File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 793, column 24, in _yarn_install_impl _create_build_files(repository_ctx, "yarn_install", node, repository_ctx.attr.yarn_lock, repository_ctx.attr.generate_local_modules_build_files) File "/private/var/tmp/_bazel_andrewjs/784c5492abc453cc085a1c5145e774ee/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 425, column 13, in _create_build_files fail("generate_build_file.ts failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr)) Error in fail: generate_build_file.ts failed: STDOUT: STDERR: could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' ERROR: no such package '@npm//@bazel/protractor': generate_build_file.ts failed: STDOUT: STDERR: could not find dependency 'google-protobuf' of '@angular/dev-infra-private/node_modules/@bazel/worker' Loading: 0 packages loaded Loading: 0 packages loaded (node:14775) UnhandledPromiseRejectionWarning: Error: Command failed: bazel query --output=label "attr('tags', '\[.*release-package.*\]', //src/...) intersect kind('.*_package', //src/...)" at checkExecSyncError (child_process.js:760:11) at Object.execSync (child_process.js:833:15) at exec (/Users/andrewjs/git/components/scripts/build-packages-dist.ts:139:18) at buildReleasePackages (/Users/andrewjs/git/components/scripts/build-packages-dist.ts:72:19) at performNpmReleaseBuild (/Users/andrewjs/git/components/scripts/build-packages-dist.ts:48:10) at /Users/andrewjs/git/components/.ng-dev/release.ts:96:12 at Generator.next (<anonymous>) at fulfilled (/Users/andrewjs/git/components/.ng-dev/release.ts:5:58) (Use `node --trace-warnings ...` to show where the warning was created) (node:14775) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:14775) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ✘ Could not build release output. Please check output above. ``` PR Close #271
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug description
General high-level description of the problem
When starting with an existing
node_modules
directory with incorrect packages,yarn install --frozen-lockfile --check-files
does install the correct versions of the packages, but sometimes fail to remove the nestednode_modules
directories deep within the previous versions of the packages.Let's say, you started on the master branch with the following
package.json
and simplifiedyarn.lock
After a
yarn install --frozen-lockfile --check-files
, you will end up with thisnode_modules
structure:This is all expected. Because our package and foo both requires incompatible versions of
bar
, there will ended up being a copy ofbar
nested inside thenode_modules
folder offoo
.Seems reasonable.
Now we will switch to and older branch with
git checkout
, which has the followingpackage.json and simplified
yarn.lock`:After a
yarn install --frozen-lockfile --check-files
, you will expect to end up with thisnode_modules
structure:However, in some situations it is possible that
yarn install --frozen-lockfile --check-files
will leave you will the followingnode_modules
structure instead:The problem here is that, while it correctly "patched"
node_modules/foo
to be1.0.0
, it didn't remove the nestednode_modules
folder. This is inconsistent with the lockfile and ultimately incorrect, because foo will get the wrong version ofbar
at runtime.The actual description of the real-world problem we encountered
I tired to recreate a minimal reproduction, but I failed at capturing the exact condition that triggers this bug. The actual bug probably requires more permissive version ranges (using ^, and just variation of compatible minor versions), deeper nesting and so on.
I do have a reliable reproduction of the problem from ember.js, just not a very minimal one. See the Command section for the exact reproduction steps.
This is a description of the actual problem we encountered. On our master branch, running
yarn install --frozen-lockfile --check-files
will result in the followingnode_modules
structure per the lockfile:We run our tests on Travis CI. Upon a successful build, it will package up the
node_modules
folder, along with the yarn cache folder into a cache tarball for subsequent builds to use. Normally, these caches are isolated to the branch they were made from.We also have a LTS branches that we support but they get new commits very infrequently. Yesterday, we opened a new PR against one of the LTS branches. Since the last build was months ago, its own cache has already been deleted (LRU up to some storage limit). So, instead, it fallback to the cache from the master branch, which means the build started off with the exact same node_modules structure we saw above.
This is not really that helpful, as the packages needed on the LTS branches are much older than the master branch, so this cache didn't really give us a very useful starting point. But no problem, we are going to run
yarn install --frozen-lockfile --check-files
, which can savage what it can from this and should still get us to the state we want, which is this according to the lockfile:Note that there shouldn't be a nested
@babel/types
inside@babel/core
, and the@babel/helper-validator-identifier
package is not needed here.However, instead, this is what we got after a successful install:
What it did right:
✅ Installed
@babel/core
7.4.5 at the root✅ Installed
@babel/types
7.4.4 at the root✅ Removed
@babel/helper-validator-identifier
from the root since nothing uses it anymoreWhat it did not do right:
❌ Remove
@babel/core/node_modules/@babel/types
which is at version 7.9.6This is incorrect because 1. it is inconsistent with what the lockfile asked for, and 2. at runtime,
@babel/core
will get the wrong copy of@babel/types
, 3. at runtime, that wrong copy of@babel/types
will fail to find@babel/helper-validator-identifier
.Here is a screenshot of it happening in action:
Our current workaround is to remove
node_modules
before installing. Obviously that is not ideal, but more concerning is the fact that we don't know what are the circumstances that triggers this bug, and if it wasn't for the missing@babel/helper-validator-identifier
dependency, if the packages are "compatible enough", it could have "worked" silently without anyone noticing, and that could have caused us to publish invalid artifacts. For example, we may not have transpiled away syntaxes that are illegal per the support matrix of the LTS version.Unfortunately, I ran out of time to reduce this down to see what the causes are, but hopefully the information here will help you find it.
Command
What is the current behavior?
node_modules/@babel/core/node_modules/@babel/types
was not removed. The last command showed version "7.9.6" was kept around erroneously.What is the expected behavior?
node_modules/@babel/core/node_modules/@babel/types
should be removed. The last command should fail due tonode_modules/@babel/core/node_modules/@babel/types/package.json
not existing.Steps to Reproduce
(See Command)
Environment
10.20.1
1.22.4
The text was updated successfully, but these errors were encountered: