rules_nodejs produces several repositories for you to reference.
Bazel represents your workspace as one repository, and code fetched or installed from outside your workspace lives in other repositories.
These are referenced with the
@repo// syntax in your BUILD files.
This repository is created by calling the
node_repositories function in your
It contains the node, npm, and npx programs.
bazel query is useful for learning about what targets are available.
$ bazel query @nodejs//...
You don't typically need to reference the
@nodejs repository from your BUILD files because it's used behind the scenes to run node and fetch dependencies.
Some ways you can use this:
- Run the Bazel-managed version of node:
bazel run @nodejs//:node path/to/program.js
- Run the Bazel-managed version of npm:
bazel run @nodejs//:npm
(Note: for backward-compatibility, the
@nodejs repository can also be referenced as