DEV Community

Ismael Garcia
Ismael Garcia

Posted on • Edited on

1 1

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

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 with the NodeJS plunging:

in the build.gradle file


task npmCi(type: NpmTask) {
    dependsOn npmSetup
    npmCommand = ["ci"]
    inputs.file("package.json")
    inputs.file("package-lock.json")
    outputs.dir("node_modules")
}
npm_run_build.dependsOn npmCi

assemble.dependsOn npm_run_build

Enter fullscreen mode Exit fullscreen mode

And for the .gitlab-ci.yml
Replace the npmInstall in the build and other parts that you're using npmInstall

script:
        - ./gradlew npmCi
        - export NODE_ENV=production
        - ./gradlew --build-cache build
Enter fullscreen mode Exit fullscreen mode
view raw socials.md hosted with ❤ by GitHub

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (1)

Collapse

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay