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

Feature: npm pkg get <value> --raw #5508

Closed

Description

@ThePlenkov

Problem
One of the most popular use cases for pkg get command is getting values for other scripts as variables. However currently it's returning the value with quotes:

npm pkg get version 
"4.12.2"

The current solution is to use it in a pipe and remove quotes somehow with sed or jq. It's ok, but this solution si not cross-platform or requires additional packages installation.

Suggestion
To introduce --raw/-r flag for npm pkg get command
Thus, for the following command we will expect the raw value:

npm pkg get version --raw
4.12.2

What do you think? It's a simple case but you can see how much discussion about this topic:
https://github.com/proxy/gist.github.com/DarrenN/8c6a5b969481725a4413
https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code

Activity

  1. ljharb commented on Sep 14, 2022

    @ljharb
    Contributor

    Seems reasonable to me - you may want to file an RFC.

  2. ThePlenkov commented on Sep 15, 2022

    @ThePlenkov
    Author

    @ljharb sure - but I don't know what is this. Do you have an example?

  3. ThePlenkov commented on Sep 15, 2022

    @ThePlenkov
    Author

    Do you mean I'd better create it here? https://github.com/npm/rfcs/issues

  4. ThePlenkov commented on Sep 15, 2022

    @ThePlenkov
    Author

    Just did: npm/rfcs#634

  5. lukekarrys commented on Nov 10, 2022

    @lukekarrys
    Contributor

    From the linked RFC (npm/rfcs#634), this is a great feature enhancement (and something I would use personally 😄). If anyone wants to implement it, the flag should be --parseable. I'm going to close the linked RFC and use this issue for tracking.

  6. mbrevda commented on Nov 24, 2022

    @mbrevda

    As the default value for the --json flag is false, this can be seen as a bug fix, not a feature and no flag should be necessary (breaking changes, etc, aside).

  7. ThePlenkov commented on Mar 18, 2023

    @ThePlenkov
    Author

    Hi! I'm really wondering will any of flags ( --raw, --parseable, --json ) be considered to print version without quotes? Thanks!

  8. alasdairhurst commented on Nov 25, 2025

    @alasdairhurst

    What would the expectation be for non-string values fetched by npm pkg get --parseable?

    For example `npm pkg get dependencies --parseable

  9. wraithgar commented on Apr 22, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancementnew feature or improvement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions