docs: Add --if-present flag documentation to workspaces · npm/cli@eda9162 (original) (raw)

Original file line number Diff line number Diff line change
@@ -176,6 +176,16 @@ npm run test --workspaces
176 176
177 177 Will run the `test` script in both `./packages/a` and `./packages/b`.
178 178
179 +### Ignoring missing scripts
180 +
181 +It is not required for all of the workspaces to implement scripts run with the `npm run` command.
182 +
183 +By running the command with the `--if-present` flag, npm will ignore workspaces missing target script.
184 +
185 +```
186 +npm run test --workspaces --if-present
187 +```
188 +
179 189 ### See also
180 190
181 191 * [npm install](/commands/npm-install)