Skip to content

[Feature] Add support for package.json script variables #1659

@jheaff1

Description

@jheaff1
  • I'd be willing to implement a fix

Describe the bug

When using "yarn pack" in Yarn v1, package.json variables (such as npm_package_version) are honoured. This seems to not be th case in yarn v2.

To Reproduce

I have a package.json which defines a "pack" script like so:

  "scripts": {
    "pack": "yarn pack --filename my-file-v$npm_package_version.tar.gz",
  }

The error when I run "yarn run pack" is Internal Error: Unbound variable "npm_package_version"

The minimal information needed to reproduce your issue (ideally a package.json with a single dep). Note that bugs without minimal reproductions might be closed.

Environment if relevant (please complete the following information):

  • OS: Linux
  • Node version 10.22.0
  • Yarn version 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions