Let's say I have cache enabled in bitbucket pipeline.
I have an npm module called `some-module@1.0.0` cached in it.
If I update the module to `some-module@2.0.0` and push it to bitbucket, will bitbucket pipeline ignore it and use the cached build of `some-module@1.0.0`?
Thanks
Hi Alex,
I don't use npm frequently, so it's possibly I've made a mistake somewhere here.
npm has some different behaviours depending on what command you run.
But in general npm follows the dependency rules set in your package.json.
Here's a reference of how the rules work: https://docs.npmjs.com/files/package.json#dependencies
tl;dir:
The following information assumes you don't have a package-lock.json file.
npm install:
If you are using 'npm install', then you will always use the local node_modules if it is retrieved via the cache exists. If a package is not present in the node_modules directory, then it will be installed. Otherwise it will follow the same rules I mention in the "npm update" section.
npm update:
npm will install the latest package based on the dependency rules set in your package.json.
For example:
"some-module" : ">=1.0.0"
"some-module" : "^1.0.0
Using npm update is good if you don't want to use dependencies that may break your pipeline.
List of references, if you'd like to do more reading:
You can test out this behaviour locally, as Pipelines will follow the same rules as in a local bash environment.
It's also worth noting that Pipelines caches expire after a week.
Thanks,
Phil
Hello Phil,
Thank you very much for the detailed answer. I will test it out when I update my modules next time.
Cheers,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.