Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Pipelines: cache custom node_modules folder

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/)? 

1 answer

1 accepted

6 votes
Answer accepted

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?

It will. You need to manually delete your cached dependencies using the UI.

There sure must be a way how to delete it automatically when package-lock.json changes?

@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.

Like Roman likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Bitbucket

How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you'll are using the integration and how it's helping your t...

160 views 0 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you