The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Do I understand correctly that pre-defined `node` cache only works when node_modules and package.json are located in the root directory of a project? Then how do I configure bitbucket-pipelines.yml to make cache work with node_modules folder located in subfolder (./public/node_modules/)?
Managed to solve it
with:
...
- step
caches:
- node-custom
script:
- if [ ! -d "node_modules" ]; then npm install; fi
...
definitions:
caches:
node-custom: public/node_modules
Will that not cause problems if package.json is updated as the node_modules won't be re-generated once cached?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It will. You need to manually delete your cached dependencies using the UI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There sure must be a way how to delete it automatically when package-lock.json changes?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Petr Pelleractually, you don't need that line:
- if [ ! -d "node_modules" ]; then npm install; fi
Because the npm knows when to install/remove packages, I just changed this line by simply:
- npm install
And it works fine for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got on this problem while trying to set up a monorepo. And even more - i want to spare the execution of costly npm command. So I generated MD5 hash of the package-lock.json and then cache node_modules AND the MD5 hash. So far looks to be working fine.
definitions:
caches:
app1: app1/node_modules
app1-cache-key: app1/package-lock.md5
pipelines:
branches:
dev:
- step:
script:
- cd app1
- package-lock.md5
- if [[ $(cat package-lock.md5 || '') != $(md5 package-lock.json) ]]; then npm ci && echo "$(md5 package-lock.json)" > package-lock.md5 ; fi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.