镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

docs: add examples for command line flags including --prefix - #8791

Merged
owlstronaut merged 1 commit into
npm:latestfrom
MaxBlack-dev:docs/8197-prefix-flag
Dec 1, 2025
Merged

owlstronaut merged 1 commit into
npm:latestfrom
MaxBlack-dev:docs/8197-prefix-flag

Conversation

@MaxBlack-dev

@MaxBlack-dev MaxBlack-dev commented Nov 30, 2025 •

Copy link
Copy Markdown
Contributor

Description

This PR adds concrete examples for command line flags, specifically documenting the --prefix\ flag that many users were unable to find in the documentation.

Changes

  • Added a 'Common examples' section under Command Line Flags
  • Documented --prefix\ flag with a clear use case example
  • Included other common flag examples (--global, --save-dev)
  • Added a note explicitly stating that any config option can be used as a command line flag

Fixes

Closes #8197

Context

Users were unable to find documentation for the --prefix\ flag, which is a commonly used option for running npm commands in different directories. While the general mechanism (any config option can be a flag) was explained, there were no concrete examples making it hard to discover. The --prefix\ flag is particularly useful in monorepos and CI/CD scripts where you want to run npm commands in subdirectories without changing the current working directory.

Type of Change

  • Documentation update

@MaxBlack-dev
MaxBlack-dev requested a review from a team as a code owner November 30, 2025 01:21
@owlstronaut
owlstronaut merged commit 39c2f2e into npm:latest Dec 1, 2025
9 checks passed
@github-actions github-actions Bot mentioned this pull request Dec 1, 2025
@ljharb

ljharb commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Note that it's a very bad idea to use --prefix, so it would have been better not to document this at all imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DOCS] The --prefix flag is not documented

3 participants