NPM CI is better than NPM install in your CI/CD

leamsigc profile image ismael garcia ・1 min read

A better and faster way to build your pipeline in a node project in general is to use the NPM CI command.

npm ci

The command offers massive improvements to both the performance and reliability of builds for continuous integration / continuous deployment processes, providing a consistent and fast experience for developers using CI/CD in their workflow.

npm ci don't use the package.json to install modules it uses the package-lock.json file. This ensures reproducible builds—you are getting exactly what you expect on every install.

Example to implement in the Gradlew whit the NodeJS plunging:

in the build.gradle file

task npmCi(type: NpmTask) {
    dependsOn npmSetup
    npmCommand = ["ci"]
npm_run_build.dependsOn npmCi

assemble.dependsOn npm_run_build

And for the .gitlab-ci.yml
Remplace the npmInstall in the build and other parts that youre using npmInstall

        - ./gradlew npmCi
        - export NODE_ENV=production
        - ./gradlew --build-cache build

Posted on by:

leamsigc profile

ismael garcia


Always ask questions to feed the curiosity and learn something new on the way. El respeto al derecho ajeno es la paz. Benito Juarez Garcia.


Editor guide