rules_node
rules_node copied to clipboard
Build fails when using the protobuf.js library
The library: protobuf.js
To reproduce (Using the latest commit to this repo):
WORKSPACE
RULES_NODE_COMMIT = 'a447bee6fec5a6b64b6b2dd5dfe0f0597c648d1c'
RULES_NODE_SHA256 = '551f19fb02f97ccb68c78ec20e4190378e46129fc9594ed01be0baa0c224ec14'
http_archive(
name = "org_pubref_rules_node",
url = "https://github.com/pubref/rules_node/archive/%s.zip" % RULES_NODE_COMMIT,
strip_prefix = "rules_node-%s" % RULES_NODE_COMMIT,
sha256 = RULES_NODE_SHA256
)
load("@org_pubref_rules_node//node:rules.bzl", "node_repositories", "yarn_modules")
node_repositories()
yarn_modules(
name = "vc_server_deps",
deps = {
"protobufjs": "~6.8.0"
}
)
BUILD
load("@org_pubref_rules_node//node:rules.bzl", "node_binary", "node_module")
node_module(
name = "server-module",
description = "Server",
srcs = [
"index.js"
],
deps = [
"@vc_server_deps//:_all_"
],
main = "index.js"
)
index.js
console.log('HELLO');
bazel build //...
.......................
ERROR: /Users/rohan/nodejstest/BUILD:3:1: no such package '@vc_server_deps//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/org_pubref_rules_node/node/internal/yarn_modules.bzl", line 66
execute(ctx, ([node, "internal/parse_yarn_...), ...)
File "/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/org_pubref_rules_node/node/internal/yarn_modules.bzl", line 4, in execute
fail((" ".join(cmds) + ("failed: \nST...))))
/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/node/bin/node internal/parse_yarn_lock.jsfailed:
STDOUT:
STDERR:
/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/vc_server_deps/internal/parse_yarn_lock.js:145
let referrer = dependency.referrer;
^
TypeError: Cannot read property 'referrer' of undefined
at Object.keys.forEach.name (/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/vc_server_deps/internal/parse_yarn_lock.js:145:34)
at Array.forEach (native)
at nodes.forEach (/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/vc_server_deps/internal/parse_yarn_lock.js:134:39)
at Array.forEach (native)
at breakCircularDependencies (/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/vc_server_deps/internal/parse_yarn_lock.js:124:9)
at main (/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/vc_server_deps/internal/parse_yarn_lock.js:46:3)
at Object.<anonymous> (/private/var/tmp/_bazel_rohan/704e4959b45a6871701648c93ca35942/external/vc_server_deps/internal/parse_yarn_lock.js:7:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
and referenced by '//:server-module'.
ERROR: Analysis of target '//:server-module' failed; build aborted: Loading failed.
INFO: Elapsed time: 11.235s
The protobuf.js library installs fine when using this library from commit dc9f8ba73f007a5eb3e57668e77082188c1ce219.
Looking into it. Looks like you are on darwin, yes? What bazel version?
I'm on darwin, bazel 0.7.0.
$bazel version
Build label: 0.7.0-homebrew
Build target: bazel-out/darwin_x86_64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Oct 19 09:13:24 2017 (1508404404)
Build timestamp: 1508404404
Build timestamp as int: 1508404404
Can also confirm that it fails with the same error on ubuntu, with bazel 0.7.0.
Hmm. I wasn't able to repro this. I added #46, let's see what travis thinks.
You got the wrong library in #46. The dependency should be "protobufjs": "~6.8.0", not "protobuf.js". Please see the link in my original post.
I created pull request #47 with a test example similar to #46, using the correct library. Let's see what Travis says about this.
I've been finding (and fixing) similar issues in parallel on a branch which I've submitted as PR #48. This particular dependency.referrer issue was because @-scope modules aren't found during the walk of the installed node_modules tree.
My (rather crude) solution for this is in 79c8825.
@rohanag12 OK, thanks for clearing that up. I'll abandon #46 and we'll keep going with #47 and #48.