HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

npm pkg — Show or modify `package.json` properties. More information: <https://docs.npmjs.com/cli/npm-pkg/>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandshowmodifyclijsonpropertiespackagenpm pkg

Problem

How to use the npm pkg command: Show or modify package.json properties. More information: <https://docs.npmjs.com/cli/npm-pkg/>.

Solution

npm pkg — Show or modify package.json properties. More information: <https://docs.npmjs.com/cli/npm-pkg/>.

Get the value of a specific property:
npm pkg get {{name}}


Get multiple properties at once:
npm pkg get {{name|version|...}}


Get multiple values across all workspaces:
npm pkg get {{name}} {{version}} {{[--ws|--workspaces]}}


Get a nested or array property value:
npm pkg get {{contributors[0].email}}


Set a property to a specific value:
npm pkg set {{property}}={{value}}


Set multiple properties at once:
npm pkg set {{property1}}={{value1}} {{property2}}={{value2}}


Delete a property from package.json:
npm pkg delete {{scripts.build}}


Auto-fix common errors in package.json:
npm pkg fix

Code Snippets

Get the value of a specific property

npm pkg get {{name}}

Get multiple properties at once

npm pkg get {{name|version|...}}

Get multiple values across all workspaces

npm pkg get {{name}} {{version}} {{[--ws|--workspaces]}}

Get a nested or array property value

npm pkg get {{contributors[0].email}}

Set a property to a specific value

npm pkg set {{property}}={{value}}

Context

tldr-pages: common/npm pkg

Revisions (0)

No revisions yet.