Skip to content

Read package.json node version

Actions
Output node version number from package.json engines field
v2.0.0
Latest
Star (5)

Read node version from engines field in package.json

Read your node version from package.json

Example workflow

package.json

{
  "name": "your-package",
  "engines": {
    "node": "12.13.x"
  }
}

.github/workflow/test.yml

name: Get node version from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Read node from package.json
        uses: culshaw/read-package-node-version-actions@v1
        id: package-node-version

      - name: Show node version number
        run: echo "Version is ${{ steps.package-node-version.outputs.version }}"
        # Version is 12.13.x

Inputs

path

Path of package.json, ./ by default.

path/to/package.json

{
  "name": "your-package",
  "engines": {
    "node": "12.13.x"
  }
}
name: Get version from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Read node from package.json
        uses: culshaw/read-package-node-version-actions@v1
        with: 
          path: "./path/to/package.json"
        id: package-node-version

      - name: Show version number
        run: echo "Version is ${{ steps.package-version.outputs.version }}"
        # Version is 12.13.x

License

MIT

Read package.json node version is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Output node version number from package.json engines field
v2.0.0
Latest

Read package.json node version is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.