Closed ex0ns closed 2 years ago
You can just pass whatever args you want to yarn, see https://docs.aspect.dev/bazelbuild/rules_nodejs/4.5.1/docs/builtins.html#yarn_install-args
does that solve it for you?
Thanks, it's indeed possible to do that, but I don't think that it work properly with the rest of our build.
I've added the following line to my yarn_install
rules: args = ["--modules-folder", "/tmp/node_modules"],
But we now have some strange issue related to paths and dependencies such as
ERROR: error loading package 'ts-api/src': Label '@npm//jest-cli:index.bzl' is invalid because 'jest-cli' is not a package; perhaps you meant to put the colon here: '@npm//:jest-cli/index.bzl'?
or even
ERROR: error loading package 'ts-frontend': Label '@npm//next:index.bzl' is invalid because 'next' is not a package; perhaps you meant to put the colon here: '@npm//:next/index.bzl'?
which is loaded like that (npm
being the yarn install repo)
load("@npm//jest-cli:index.bzl", "jest_test")
And similar for Next.js. I think that there is more to it, and I don't know if this is related to bazel, yarn or anything else in this case. Thanks for the pointer though (it's probably related to the managed_directories
from the WORKSPACE
but I have no idea on how to cutomize that based on a environment variable anyway...)
Curious, did you close this after solving those problems?
No, I was just hitting stranger and stranger problem, furthermore we have a lot of path and tooling that are looking for node_modules inside a specific location (I tried to emulate something with a symlink but it did not change anything).
I guess it might be possible if spending some (a lot) of time, or if starting from scratch, but jest and Next.js were pretty annoyed by the change.
One of the biggest issue was that managed_directories
can only accept relative path that are under the root, and the cache folder is definitely not mounted inside the project's repo in the pipeline.
Hello
I would like to cache the
node_modules
folder in between run of my CI, however I do not control it, I'm only provided a environment variable calledCI_CACHE_DIR
which I can use to cache data.I could not find any information on
yarn_install
to change the location of thenode_modules
directory for it to be put inside the cache. Is there a way to achieve this ?Thanks