Skip to content

@nodejs_host//:yarn no such target #3530

Description

@dgnemo

🐞 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

https://github.com/bazelbuild/rules_nodejs/blob/80df1aa4cf39782c12ef8a8959f8c96803c74ab6/internal/npm_install/npm_install.bzl#L1015

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions