@nodejs_host//:yarn no such target
dgnemo opened this issue Β· comments
π bug report
In multiple place in the code and in the documentation it's mentioned to execute
bazel run @nodejs_host//:yarn install
to update a dependency or install a new one
rules_nodejs/internal/npm_install/npm_install.bzl
Line 1015 in 80df1aa
but the command bazel run @nodejs_host//:yarn install
does not work (target does not exist),
even on a repo created following the quickstart directions.
π¬ Minimal Reproduction
$ npx @bazel/create workspace --packageManager=yarn
Creating Bazel workspace workspace...
Successfully created new Bazel workspace at /home/diego/js-bazel-test/workspace
Next steps:
1. cd workspace
2. yarn install
3. yarn build
Note that there is nothing to build, so this trivially succeeds.
4. Add contents to the BUILD.bazel file or create a new BUILD.bazel in a subdirectory.
$ cd workspace
$ bazel run @nodejs_host//:yarn
INFO: Invocation ID: 714bcd52-86e6-41d8-bf43-3487a91f6d99
ERROR: Skipping '@nodejs_host//:yarn': no such target '@nodejs_host//:yarn': target 'yarn' not declared in package '' defined by /home/--/.cache/bazel/_bazel_--/6ab1a205e0a75010d0a8dd8cfcbcb536/external/nodejs_host/BUILD.bazel
WARNING: Target pattern parsing failed.
ERROR: no such target '@nodejs_host//:yarn': target 'yarn' not declared in package '' defined by /home/--/.cache/bazel/_bazel_--/6ab1a205e0a75010d0a8dd8cfcbcb536/external/nodejs_host/BUILD.bazel
INFO: Elapsed time: 0.473s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
$ bazel query @nodejs_host//...
@nodejs_host//:node
@nodejs_host//:node_bin
@nodejs_host//:node_files
@nodejs_host//:npm
@nodejs_host//:npm_bin
@nodejs_host//:npm_files
@nodejs_host//:npx_bin
@nodejs_host//:run_npm.bat.template
@nodejs_host//:run_npm.sh.template
Loading: 0 packages loaded
π₯ Exception or Error
'@nodejs_host//:yarn': no such target '@nodejs_host//:yarn': target 'yarn' not declared in package ''
defined by /home/--/.cache/bazel/_bazel_--/6ab1a205e0a75010d0a8dd8cfcbcb536/external/nodejs_host/BUILD.bazel
π Your Environment
Operating System: Linux
Output of bazel version
:
$ bazel version
Bazelisk version: development
Build label: 5.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:08:54 2022 (1642601334)
Build timestamp: 1642601334
Build timestamp as int: 1642601334
Rules_nodejs version: 5.5.3
In 5.0 it was moved: https://bazelbuild.github.io/rules_nodejs/repositories.html#yarn