bazel-contrib / rules_nodejs

NodeJS toolchain for Bazel.
https://bazelbuild.github.io/rules_nodejs/
Apache License 2.0
727 stars 522 forks source link

Windows: Karma tests pick wrong node_modules folder #2150

Closed plule-ansys closed 3 years ago

plule-ansys commented 4 years ago

🐞 bug report

Affected Rule

The issue is visible in the rule `karma_web_test_suite()` ### Is this a regression? Not that I know ### Description With `package.json`, `yarn.lock` and `node_modules` located in a subfolder, the `karma_web_test_suite()` will fail if there is another `node_modules` folder located at the root folder. When launching the test, this other `node_modules` folder will be picked up. If it doesn’t exist, this scenario works fine. ## 🔬 Minimal Reproduction Extract attachment [rules_nodejs_node_modules_subfolder.zip](https://github.com/bazelbuild/rules_nodejs/files/5134919/rules_nodejs_node_modules_subfolder.zip). This is the `example_webtesting` example moved to a subfolder, and an additional dummy `node_modules` folder at the root. `bazel test //...` fails. Remove the `node_modules` folder located at the root of the workspace. `bazel test //...` succeed. ## 🔥 Exception or Error The test log fails with:

Running karma tests
-----------------------------------------------------------------------------
version     : 4.1.0
pwd         : /c/users/plule/_bazel_plule/czpp2oy5/execroot/rules_nodejs_node_modules_subfolder/bazel-out/x64_windows-fastbuild/bin/subfolder/config_test_chromium-local.bat.runfiles/rules_nodejs_node_modules_subfolder
conf        : C:/users/plule/_bazel_plule/czpp2oy5/execroot/rules_nodejs_node_modules_subfolder/bazel-out/x64_windows-fastbuild/bin/subfolder/config_test_wrapped_test.conf.js
node_options:
Error in karma configuration Error: Cannot find module 'tmp'
Require stack:
- C:\users\plule\_bazel_plule\czpp2oy5\execroot\rules_nodejs_node_modules_subfolder\bazel-out\x64_windows-fastbuild\bin\subfolder\config_test_wrapped_test.conf.js
- C:\users\plule\_bazel_plule\czpp2oy5\external\npm\node_modules\karma\lib\config.js
- C:\users\plule\_bazel_plule\czpp2oy5\external\npm\node_modules\karma\lib\server.js
- C:\users\plule\_bazel_plule\czpp2oy5\external\npm\node_modules\karma\lib\cli.js
- C:\users\plule\_bazel_plule\czpp2oy5\external\npm\node_modules\karma\bin\karma
27 08 2020 10:13:31.493:ERROR [config]: File C:\users\plule\_bazel_plule\czpp2oy5\execroot\rules_nodejs_node_modules_subfolder\bazel-out\x64_windows-fastbuild\bin\subfolder\config_test_wrapped_test.conf.js does not exist!
(Probably irrelevant) In both succeeded and failing scenarios, the debug build log contains a lot of: ``` DEBUG: C:/users/plule/_bazel_plule/czpp2oy5/external/build_bazel_rules_nodejs/internal/linker/link_node_modules.bzl:19:14: [link_node_modules.bzl] No LinkablePackageInfo for @npm//ent:ent__nested_node_modules ``` ## 🌍 Your Environment **Operating System:**
  
Windows 10 1903
  
**Output of `bazel version`:**
  
3.4.1
3.0.0
  
**Rules_nodejs version:**
  
rules_nodejs-2.0.3
  
**Anything else relevant?** Loosely related #1373 but there is nothing about a folder being picked in priority or not, or being specific to Windows On Linux, I don't have any difference with or without this folder.
github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

plule-ansys commented 3 years ago

Hello, attached is a reproduction with the latest version of rules_nodejs

rules_nodejs_node_modules_subfolder.zip

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

github-actions[bot] commented 3 years ago

This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"