I'm relatively new to Bazel but this has taken longer than I felt it should. I am doing yarn_install
in my workspace, and I am just trying to reference the installed node_modules
so that I can put them in my new docker container.
Workspace
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
BUILD.bazel
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
nodejs_image(
name = "webapi_image",
# gets all the files in my directory
data = glob(
[
"**/*",
],
# references the node modules, but doesn't work :(
) + ["@npm//node_modules"],
entry_point = "//:app.js",
)
I've been able to get specific packages (i.e. @npm//express
) but if I try to access node_modules then I just get
no such package '@npm//node_modules': Package is considered deleted due to --deleted_packages and referenced by '//:webapi_image'
I'm not sure I totally understand why I can access individual packages (i.e. @npm//express
) but not node_modules (i.e. @npm//node_modules
).
but after bumping around, I found if I just use the structure @npm//:node_modules
, then it works finally.