Repository navigation
Closed
Description
🐞 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
🔥 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?
Metadata
Metadata
Assignees
Labels
No labels
Activity
alexeagle commentedon Mar 27, 2019
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.
jmaher409 commentedon Mar 27, 2019
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.
rehmsen commentedon May 15, 2019
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 installdirectly works, so I think this is not an issue with thepackage.json? Any idea what I am getting wrong?You can repro by running
Initial Toolchain Support