Skip to content

Commit 8c5ef3d

Browse files
author
Michael Smith
committed
feat!: drop npm-shrinkwrap.json support
BREAKING CHANGE: `npm shrinkwrap` is removed, the `shrinkwrap` config alias is removed, and `npm-shrinkwrap.json` is no longer loaded or honored at the project root or from inside dependency tarballs. Rename project-root `npm-shrinkwrap.json` to `package-lock.json`; use `bundleDependencies` if you need to ship a locked dependency tree.
1 parent 27567ab commit 8c5ef3d

57 files changed

Lines changed: 381 additions & 3967 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/lib/build.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ const generateNav = async (contentPath, navPath) => {
105105
'/configuring-npm/install',
106106
'/configuring-npm/folders',
107107
'/configuring-npm/npmrc',
108-
'/configuring-npm/npm-shrinkwrap-json',
109108
'/configuring-npm/package-json',
110109
'/configuring-npm/package-lock-json',
111110
]

‎docs/lib/content/commands/npm-shrinkwrap.md‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎docs/lib/content/commands/npm-version.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ description: Bump a package version
1414

1515
### Description
1616

17-
Run this in a package directory to bump the version and write the new data back to `package.json`, `package-lock.json`, and, if present,
18-
`npm-shrinkwrap.json`.
17+
Run this in a package directory to bump the version and write the new data back to `package.json` and `package-lock.json`.
1918

2019
The `newversion` argument should be a valid semver string, a valid second argument to [semver.inc](https://github.com/npm/node-semver#functions) (one of `patch`, `minor`, `major`, `prepatch`, `preminor`, `premajor`, `prerelease`), or `from-git`.
2120
In the second case, the existing version will be incremented by 1 in the specified field.

‎docs/lib/content/configuring-npm/npm-shrinkwrap-json.md‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎docs/lib/content/configuring-npm/package-json.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Some files are always ignored by default:
301301
* `config.gypi`
302302
* `node_modules`
303303
* `npm-debug.log`
304-
* `package-lock.json` (use [`npm-shrinkwrap.json`](/configuring-npm/npm-shrinkwrap-json) if you wish it to be published)
304+
* `package-lock.json`
305305
* `pnpm-lock.yaml`
306306
* `yarn.lock`
307307
* `bun.lockb`
@@ -872,7 +872,7 @@ These changes can be scoped as specific or as vague as desired.
872872

873873
Overrides are only considered in the root `package.json` file for a project.
874874
Overrides in installed dependencies (including [workspaces](/using-npm/workspaces)) are not considered in dependency tree resolution.
875-
Published packages may dictate their resolutions by pinning dependencies or using an [`npm-shrinkwrap.json`](/configuring-npm/npm-shrinkwrap-json) file.
875+
Published packages may dictate their resolutions by pinning dependencies or using [`bundleDependencies`](#bundledependencies).
876876

877877
To make sure the package `@npm/foo` is always installed as version `1.0.0` no matter what version your dependencies rely on:
878878

‎docs/lib/content/configuring-npm/package-lock-json.md‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ This file is intended to be committed into source repositories, and serves vario
2323

2424
When `npm` creates or updates `package-lock.json`, it will infer line endings and indentation from `package.json` so that the formatting of both files matches.
2525

26-
### `package-lock.json` vs `npm-shrinkwrap.json`
26+
### `npm-shrinkwrap.json`
2727

28-
Both of these files have the same format, and perform similar functions in the root of a project.
29-
30-
The difference is that `package-lock.json` cannot be published, and it will be ignored if found in any place other than the root project.
31-
32-
In contrast, [npm-shrinkwrap.json](/configuring-npm/npm-shrinkwrap-json) allows publication, and defines the dependency tree from the point encountered.
33-
This is not recommended unless deploying a CLI tool or otherwise using the publication process for producing production packages.
34-
35-
If both `package-lock.json` and `npm-shrinkwrap.json` are present in the root of a project, `npm-shrinkwrap.json` will take precedence and `package-lock.json` will be ignored.
28+
As of npm v12, `npm-shrinkwrap.json` is no longer read or written by
29+
npm. Projects that previously committed `npm-shrinkwrap.json` should
30+
rename it to `package-lock.json`; the file format is identical. When
31+
npm v12 encounters a dependency that ships an `npm-shrinkwrap.json`
32+
inside its tarball, the file is ignored — publishers who need to ship
33+
a locked tree should use
34+
[`bundleDependencies`](/configuring-npm/package-json#bundledependencies)
35+
instead.
3636

3737
### Hidden Lockfiles
3838

@@ -115,8 +115,6 @@ Package descriptors have the following fields:
115115

116116
* hasInstallScript: A flag to indicate that the package has a `preinstall`, `install`, or `postinstall` script.
117117

118-
* hasShrinkwrap: A flag to indicate that the package has an `npm-shrinkwrap.json` file.
119-
120118
* bin, license, engines, dependencies, optionalDependencies: fields from `package.json`
121119

122120
* os: An array of operating systems this package is compatible with, as specified in `package.json`. This field is included when the package specifies OS restrictions.
@@ -176,7 +174,5 @@ Dependency objects have the following fields:
176174

177175
### See also
178176

179-
* [npm shrinkwrap](/commands/npm-shrinkwrap)
180-
* [npm-shrinkwrap.json](/configuring-npm/npm-shrinkwrap-json)
181177
* [package.json](/configuring-npm/package-json)
182178
* [npm install](/commands/npm-install)

‎docs/lib/content/nav.yml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@
159159
- title: npm set
160160
url: /commands/npm-set
161161
description: Set a value in the npm configuration
162-
- title: npm shrinkwrap
163-
url: /commands/npm-shrinkwrap
164-
description: Lock down dependency versions for publication
165162
- title: npm start
166163
url: /commands/npm-start
167164
description: Start a package
@@ -217,9 +214,6 @@
217214
- title: .npmrc
218215
url: /configuring-npm/npmrc
219216
description: The npm config files
220-
- title: npm-shrinkwrap.json
221-
url: /configuring-npm/npm-shrinkwrap-json
222-
description: A publishable lockfile
223217
- title: package.json
224218
url: /configuring-npm/package-json
225219
description: Specifics of npm's package.json handling

‎lib/commands/ci.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ class CI extends ArboristWorkspaceCmd {
5555
} catch (err) {
5656
log.verbose('loadVirtual', err.stack)
5757
const msg =
58-
'The `npm ci` command can only install with an existing package-lock.json or\n' +
59-
'npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or\n' +
60-
'later to generate a package-lock.json file, then try again.'
58+
'The `npm ci` command can only install with an existing\n' +
59+
'package-lock.json with lockfileVersion >= 1. Run an install with npm@5\n' +
60+
'or later to generate a package-lock.json file, then try again.'
6161
throw this.usageError(msg)
6262
}
6363
const virtualInventory = new Map(virtualArb.virtualTree.inventory)
@@ -71,7 +71,7 @@ class CI extends ArboristWorkspaceCmd {
7171
const errors = validateLockfile(virtualInventory, arb.idealTree.inventory)
7272
if (errors.length) {
7373
throw this.usageError(
74-
'`npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. ' +
74+
'`npm ci` can only install packages when your package.json and package-lock.json are in sync. ' +
7575
'Please update your lock file with `npm install` before continuing.\n\n' +
7676
errors.join('\n')
7777
)

‎lib/commands/query.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Query extends BaseCommand {
7272
} catch (err) {
7373
log.verbose('loadVirtual', err.stack)
7474
throw this.usageError(
75-
'A package lock or shrinkwrap file is required in package-lock-only mode'
75+
'A package-lock.json file is required in package-lock-only mode'
7676
)
7777
}
7878
} else {
@@ -98,7 +98,7 @@ class Query extends BaseCommand {
9898
} catch (err) {
9999
log.verbose('loadVirtual', err.stack)
100100
throw this.usageError(
101-
'A package lock or shrinkwrap file is required in package-lock-only mode'
101+
'A package-lock.json file is required in package-lock-only mode'
102102
)
103103
}
104104
} else {

‎lib/commands/sbom.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SBOM extends BaseCommand {
3939
const arb = new Arborist(opts)
4040

4141
const tree = packageLockOnly ? await arb.loadVirtual(opts).catch(() => {
42-
throw this.usageError('A package lock or shrinkwrap file is required in package-lock-only mode')
42+
throw this.usageError('A package-lock.json file is required in package-lock-only mode')
4343
}) : await arb.loadActual(opts)
4444

4545
// Collect the list of selected workspaces in the project

0 commit comments

Comments
 (0)