← 返回命令列表

Linux command

package-lock.json 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create or update

npm install

Clean install from lock file

npm ci

Update a specific package

npm update [package]

Audit

npm audit

Inspect changes

git diff package-lock.json

Regenerate

rm package-lock.json && npm install

说明

package-lock.json is automatically generated by npm to describe the exact tree of dependencies that was installed. It records every resolved version, the registry URL, and an integrity hash (SRI), so subsequent installs produce the same node_modules regardless of which semver range the manifest allows. The file should be committed to version control. In CI, use npm ci instead of npm install: npm ci installs directly from the lock file without touching it, fails fast if it drifts from package.json, and is significantly faster.

FAQ

What is the package-lock.json command used for?

package-lock.json is automatically generated by npm to describe the exact tree of dependencies that was installed. It records every resolved version, the registry URL, and an integrity hash (SRI), so subsequent installs produce the same node_modules regardless of which semver range the manifest allows. The file should be committed to version control. In CI, use npm ci instead of npm install: npm ci installs directly from the lock file without touching it, fails fast if it drifts from package.json, and is significantly faster.

How do I run a basic package-lock.json example?

Run `npm install` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more package-lock.json examples?

This page includes 6 examples for package-lock.json, plus related commands for nearby Linux tasks.