> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# dockerfile-npm-install

> A Dockerfile runs `npm install` after copying the lockfile, so the image can resolve versions the lockfile does not pin.

## What it flags

A `RUN npm install` or `RUN npm i` (shell form, exec form, or a line of a `RUN <<EOF` heredoc), with only flags, redirections (`> /dev/null`, `2>&1`) and an optional shell comment after it (options that take a separate value, such as `--registry <url>`, `--omit dev` or `--tag next`, count as flags), npm options allowed before the subcommand (`npm --prefix /app install`), optionally after `NAME=value` assignments (quoted values may contain spaces), an `if`, `while`, `until`, `then`, `do` or `else` keyword, a `!` negation, or inside `sh -c "..."` (also `bash`, `dash`, `ash` and `zsh`, and combined flags such as `bash -lc`), in a stage that has already copied `package-lock.json` or `npm-shrinkwrap.json` by name (or builds `FROM` an earlier stage that did), or that bind-mounts the lockfile into the same `RUN`. The `package*.json` glob counts only when a `package-lock.json` sits beside the Dockerfile (the glob does not match `npm-shrinkwrap.json`). When `package.json` and the lockfile disagree, `npm install` resolves other versions and rewrites the lockfile instead of failing. `npm ci` installs exactly the locked tree and is usually faster in a clean image.

Not flagged: text that is only printed or quoted (`echo "cd app && npm install"`), `npm ci`, installing named packages (`npm install -g pnpm`), `npm install --no-package-lock`, `--package-lock=false` or `--package-lock-only` (before or after the subcommand), a stage that copied only `package.json`, the `package*.json` glob with no lockfile beside the Dockerfile, and `COPY . .` (the rule cannot tell whether the build context has a lockfile). The build context is set outside the Dockerfile (`docker build <dir>`, a compose `context:`), so the glob is judged against the Dockerfile's own folder. Yarn and pnpm installs are not checked.

```dockerfile theme={null}
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
```

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "dockerfile-npm-install": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.