You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+13-9Lines changed: 13 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ $ np --help
74
74
$ np <version>
75
75
76
76
Version can be:
77
-
major | minor | patch | premajor | preminor | prepatch | prerelease | 1.2.3
77
+
patch | minor | major | prepatch | preminor | premajor | prerelease | 1.2.3
78
78
79
79
Options
80
80
--any-branch Allow publishing from any branch
@@ -85,13 +85,13 @@ $ np --help
85
85
--no-publish Skips publishing
86
86
--preview Show tasks without actually executing them
87
87
--tag Publish under a given dist-tag
88
-
--no-yarn Don't use Yarn
89
88
--contents Subdirectory to publish
90
89
--no-release-draft Skips opening a GitHub release draft
91
90
--release-draft-only Only opens a GitHub release draft for the latest published version
92
91
--test-script Name of npm run script to run tests before publishing (default: test)
93
92
--no-2fa Don't enable 2FA on new packages (not recommended)
94
-
--message Version bump commit message. `%s` will be replaced with version. (default: '%s' with npm and 'v%s' with yarn)
93
+
--message Version bump commit message, '%s' will be replaced with version (default: '%s' with npm and 'v%s' with yarn)
94
+
--package-manager Use a specific package manager (default: 'packageManager' field in package.json)
95
95
96
96
Examples
97
97
$ np
@@ -121,21 +121,21 @@ Currently, these are the flags you can configure:
121
121
-`publish` - Publish (`true` by default).
122
122
-`preview` - Show tasks without actually executing them (`false` by default).
123
123
-`tag` - Publish under a given dist-tag (`latest` by default).
124
-
-`yarn` - Use yarn if possible (`true` by default).
125
124
-`contents` - Subdirectory to publish (`.` by default).
126
125
-`releaseDraft` - Open a GitHub release draft after releasing (`true` by default).
127
126
-`testScript` - Name of npm run script to run tests before publishing (`test` by default).
128
127
-`2fa` - Enable 2FA on new packages (`true` by default) (setting this to `false` is not recommended).
129
128
-`message` - The commit message used for the version bump. Any `%s` in the string will be replaced with the new version. By default, npm uses `%s` and Yarn uses `v%s`.
129
+
-`packageManager` - Set the package manager to be used. Defaults to the [packageManager field in package.json](https://nodejs.org/api/packages.html#packagemanager), so only use if you can't update package.json for some reason.
130
130
131
-
For example, this configures `np` to never use Yarn and to use `dist` as the subdirectory to publish:
131
+
For example, this configures `np` to use `unit-test` as a test script, and to use `dist` as the subdirectory to publish:
132
132
133
133
`package.json`
134
134
```json
135
135
{
136
136
"name": "superb-package",
137
137
"np": {
138
-
"yarn": false,
138
+
"testScript": "unit-test",
139
139
"contents": "dist"
140
140
}
141
141
}
@@ -144,23 +144,23 @@ For example, this configures `np` to never use Yarn and to use `dist` as the sub
144
144
`.np-config.json`
145
145
```json
146
146
{
147
-
"yarn": false,
147
+
"testScript": "unit-test",
148
148
"contents": "dist"
149
149
}
150
150
```
151
151
152
152
`.np-config.js` or `.np-config.cjs`
153
153
```js
154
154
module.exports= {
155
-
yarn:false,
155
+
testScript:'unit-test',
156
156
contents:'dist'
157
157
};
158
158
```
159
159
160
160
`.np-config.mjs`
161
161
```js
162
162
exportdefault {
163
-
yarn:false,
163
+
testScript:'unit-test',
164
164
contents:'dist'
165
165
};
166
166
```
@@ -276,6 +276,10 @@ Set the [`registry` option](https://docs.npmjs.com/misc/config#registry) in pack
276
276
}
277
277
```
278
278
279
+
### Package managers
280
+
281
+
If a package manager is not set in package.json, via configuration (`packageManager`), or via the CLI (`--package-manager`), `np` will attempt to infer the best package manager to use by looking for lockfiles. But it's recommended to set the [`packageManager` field](https://nodejs.org/api/packages.html#packagemanager) in your package.json to be consistent with other tools. See also the [corepack docs](https://nodejs.org/api/corepack.html).
282
+
279
283
### Publish with a CI
280
284
281
285
If you use a Continuous Integration server to publish your tagged commits, use the `--no-publish` flag to skip the publishing step of `np`.
0 commit comments