Skip to content

"no such package '@npm//" error while running quickstart steps #628

Closed

Description

@jmaher409

🐞 bug report

Affected Rule

N/A

Is this a regression?

Unknown.

Description

I hit a "no such package '@npm//" error while trying to setup bazel using the quickstart steps in a mono repo I maintain.

🔬 Minimal Reproduction

https://github.com/jmaher409/reproduce-bazel-quickstart-bug

🔥 Exception or Error


 bazel git:(yarn-installed-bazel) ✗ yarn bazelBuild
 yarn run v1.13.0
 $ bazel build //...
 ERROR: error loading package '': Encountered error while reading extension file 'install_bazel_dependencies.bzl': no such package '@npm//': Traceback (most recent call last):
         File "/private/var/tmp/_bazel_justinmah/684a432d68d5cb4f45acf4255d4873d0/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 237
                         repository_ctx.template("yarn.lock", repository_ctx.path(r...), {})
                                 File "/private/var/tmp/_bazel_justinmah/684a432d68d5cb4f45acf4255d4873d0/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 239, in repository_ctx.template
                                                 repository_ctx.path(repository_ctx.attr.yarn_lock)
  Unable to load package for //:yarn.lock: not found.
  ERROR: error loading package '': Encountered error while reading extension file 'install_bazel_dependencies.bzl': no such package '@npm//': Traceback (most recent call last):
          File "/private/var/tmp/_bazel_justinmah/684a432d68d5cb4f45acf4255d4873d0/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 237
                          repository_ctx.template("yarn.lock", repository_ctx.path(r...), {})
                                  File "/private/var/tmp/_bazel_justinmah/684a432d68d5cb4f45acf4255d4873d0/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 239, in repository_ctx.template
                                                  repository_ctx.path(repository_ctx.attr.yarn_lock)
  Unable to load package for //:yarn.lock: not found.
  INFO: Elapsed time: 0.127s
  INFO: 0 processes.
  FAILED: Build did NOT complete successfully (0 packages loaded)
      Fetching @npm; fetching
      error Command failed with exit code 1.


🌍 Your Environment

Operating System:

  
macOS Mojave 10.14
  

Output of bazel version:

  
0.23.2
  

Rules version (SHA):

  
88e5e579fb9edfbd19791b8a3c6bfbe16ae3444dba4b428e5efd36856db7cf16
  

Anything else relevant?

Activity

  1. alexeagle commented on Mar 27, 2019

    @alexeagle
    Collaborator

    Thanks, the root cause here is Bazel printed a bad error message, I filed that upstream: bazelbuild/bazel#7854

    The error should have been "You don't have a BUILD.bazel file next to the yarn.lock file"

    Even an empty file there will signal to Bazel that the directory is a "package".

    You're also right that the quickstart instructions are missing this.

  2. jmaher409 commented on Mar 27, 2019

    @jmaher409
    Author

    Thanks @alexeagle ! That makes sense. Sorry for the newbie question. Also thanks for all the work you all are doing on this and the typescript rules. I have been following closely and it seems like it is at the point where we can start adopting.

  3. rehmsen commented on May 15, 2019

    @rehmsen

    Posting here as the bug template suggest finding closed issues about the same error. I don't think mine has the same root cause - let me know if you prefer me to file a new one.

    Context: https://gerrit-review.googlesource.com/c/gerrit/+/224476

    I follow the same intro steps, and get the same error. However, in my case I do have an empty BUILD.bazel file and that does not solve it (I am also unsure if I need it, I have a BUILD file already which I think should tell bazel that it's a package?). I also get a second error about a missing peer dependency, not sure if that is caused by the first error. Running npm install directly works, so I think this is not an issue with the package.json? Any idea what I am getting wrong?

    You can repro by running

    git fetch "https://gerrit.googlesource.com/gerrit" refs/changes/76/224476/1 && git checkout FETCH_HEAD
    bazel build //...
    
  4. added a commit that references this issue on Jun 6, 2019
    188ae59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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