npmcontinuous-integrationpnpmnpm-ci

pnpm equivalent command for npm ci


What is the equivalent command for npm ci in pnpm?

According to the documentation for npm install:

pnpm install is used to install all dependencies for a project.

In a CI environment, installation fails if a lockfile is present but needs an update.

How is the "CI environment" defined?

What does the following mean? Dependencies could be updated, but the pnpm-lock.yaml is not touched?

pnpm i --frozen-lockfile # pnpm-lock.yaml is not updated


Solution

  • What is the equivalent command for npm ci in pnpm?

    The equivalent is

    pnpm install --frozen-lockfile
    

    However, even if you don't use --frozen-lockfile, pnpm will automatically use a faster installation strategy if the lockfile is up-to-date. This is controlled by the prefer-frozen-lockfile setting which is true by default.

    How is the "CI environment" defined?

    pnpm uses the is-ci package to detect whether the environment is a CI.

    pnpm i --frozen-lockfile # pnpm-lock.yaml is not updated

    It means that if the lockfile is not up-to-date with the package.json file then pnpm install will throw an exception instead of updating the lockfile. If the lockfile is up-to-date, pnpm will do any necessary updates to the node_modules.