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

Error in bazel run :rollup when following the document #1727

Closed
yujunz opened this issue Mar 24, 2020 · 1 comment · Fixed by #1733
Closed

Error in bazel run :rollup when following the document #1727

yujunz opened this issue Mar 24, 2020 · 1 comment · Fixed by #1733

Comments

@yujunz
Copy link
Contributor

yujunz commented Mar 24, 2020

🐞 bug report

Affected Rule

The issue is caused by the rule: nodejs_binary

Is this a regression?

Not sure

Description

Errors when trying out the example usage

🔬 Minimal Reproduction

Follow the steps in https://bazelbuild.github.io/rules_nodejs/#usage until the step bazel run:rollup -- --help

🔥 Exception or Error

❯ bazel run :rollup --define=VERBOSE_LOGS=1 -- --help
INFO: Invocation ID: 3c1df155-1337-4567-9bc3-d6f074b16c8b
INFO: Analyzed target //:rollup (22 packages loaded, 71 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/sandbox
Target //:rollup up-to-date:
  dist/bin/rollup.sh
  dist/bin/rollup_loader.js
  dist/bin/rollup_require_patch.js
INFO: Elapsed time: 1.940s, Critical Path: 0.03s
INFO: 0 processes.
INFO: Build completed successfully, 2 total actions
INFO: Build completed successfully, 2 total actions
[rollup_require_patch.js] patching require for //:rollup
  cwd: /private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup.sh.runfiles/bazel_nodejs_quickstart
  RUNFILES: /private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup.sh.runfiles
  TARGET: //:rollup
  BIN_DIR: bazel-out/darwin-fastbuild/bin
  GEN_DIR: bazel-out/darwin-fastbuild/bin
  INSTALL_SOURCE_MAP_SUPPORT: true
  MODULE_ROOTS: []
  NODE_MODULES_ROOT: build_bazel_rules_nodejs/node_modules
  USER_WORKSPACE_NAME: bazel_nodejs_quickstart

[rollup_require_patch.js] try to resolve in runfiles /private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup.sh.runfiles/bazel_nodejs_quickstart/node_modules/rollup/bin/rollup
[rollup_require_patch.js] try to resolve in runfiles /private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup.sh.runfiles/build_bazel_rules_nodejs/node_modules/bazel_nodejs_quickstart/node_modules/rollup/bin/rollup
Error: Cannot find module 'bazel_nodejs_quickstart/node_modules/rollup/bin/rollup'. Please verify that the package.json has a valid "main" entry
required in target //:rollup by 'undefined'
  looked in:
    built-in, relative, absolute, nested node_modules - Error: Cannot find module 'bazel_nodejs_quickstart/node_modules/rollup/bin/rollup'
Require stack:
-
    runfiles - Error: Cannot find module '/private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup.sh.runfiles/bazel_nodejs_quickstart/node_modules/rollup/bin/rollup'
Require stack:
-
    node_modules attribute (build_bazel_rules_nodejs/node_modules) - Error: Cannot find module '/private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup.sh.runfiles/build_bazel_rules_nodejs/node_modules/bazel_nodejs_quickstart/node_modules/rollup/bin/rollup'
Require stack:
-

    at Function.module.constructor._resolveFilename (/private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup_require_patch.js:482:17)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Object.<anonymous> (/private/var/tmp/_bazel_yujunz/a95322c336466e88acb40e8f0ae808b7/execroot/bazel_nodejs_quickstart/bazel-out/darwin-fastbuild/bin/rollup_loader.js:32:24)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11

🌍 Your Environment

Operating System:

macOS Catalina

Output of bazel version:

Build label: 2.1.1-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sat Feb 22 21:28:00 2020 (1582406880)
Build timestamp: 1582406880
Build timestamp as int: 1582406880

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

    sha256 = "2eca5b934dee47b5ff304f502ae187c40ec4e33e12bcbce872a2eeb786e23269",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.4.1/rules_nodejs-1.4.1.tar.gz"],

Anything else relevant?

The repository for testing: https://github.com/yujunz/bazel_nodejs_quickstart/tree/rollup

@alexeagle
Copy link
Collaborator

Yeah sorry, that documentation is out-of-date.

bazel run @npm//rollup/bin:rollup is the simpler way to run a tool from npm now (you don't need to write nodejs_binary at all, since we automatically make one for every bin entry in the node_modules)

I'll take a stab at improving that doc...

alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Mar 25, 2020
This teaches you to use generated npm_package_bin rules rather than getting into details about writing custom rules with nodejs_binary

Fixes bazel-contrib#1727
alexeagle added a commit that referenced this issue Mar 26, 2020
This teaches you to use generated npm_package_bin rules rather than getting into details about writing custom rules with nodejs_binary

Fixes #1727
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

Successfully merging a pull request may close this issue.

2 participants