deps/npm/docs/output/commands/npm-pkg.html
npm pkg set <key>=<value> [<key>=<value> ...]
npm pkg get [<key> [<key> ...]]
npm pkg delete <key> [<key> ...]
npm pkg set [<array>[<index>].<key>=<value> ...]
npm pkg set [<array>[].<key>=<value> ...]
npm pkg fix
A command that automates the management of package.json files. npm pkg provide 3 different sub commands that allow you to modify or retrieve values for given object keys in your package.json.
The syntax to retrieve and set fields is a dot separated representation of the nested object properties to be found within your package.json, it's the same notation used in npm view to retrieve information from the registry manifest, below you can find more examples on how to use it.
Returned values are always in json format.
npm pkg get <field>
npm pkg set <field>=<value>
npm pkg delete <key>
npm pkg fix
You can set/get/delete items across your configured workspaces by using the workspace or workspaces config options.
For example, setting a funding value across all configured workspaces of a project:
npm pkg set funding=https://example.com --ws
When using npm pkg get to retrieve info from your configured workspaces, the returned result will be in a json format in which top level keys are the names of each workspace, the values of these keys will be the result values returned from each of the configured workspaces, e.g:
npm pkg get name version --ws
{
"a": {
"name": "a",
"version": "1.0.0"
},
"b": {
"name": "b",
"version": "1.0.0"
}
}
forceRemoves various protections against unfortunate side effects, common mistakes, unnecessary performance degradation, and malicious input.
npm version command to work on an unclean git repository.npm cache clean.engines declaration requiring a different version of npm.engines declaration requiring a different version of node, even if --engine-strict is enabled.npm audit fix to install modules outside your stated dependency range (including SemVer-major changes).--yes during npm init.npm pkgIf you don't have a clear idea of what you want to do, it is strongly recommended that you do not use this option!
jsonWhether or not to output JSON data, rather than the normal output.
npm pkg set it enables parsing set values with JSON.parse() before saving them to your package.json.Not supported by all npm commands.
workspaceEnable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
Valid values for the workspace config are either:
When set for the npm init command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.
This value is not exported to the environment for child processes.
workspacesSet to true to run the command in the context of all configured workspaces.
Explicitly setting this to false will cause commands like install to ignore workspaces altogether. When not set explicitly:
node_modules tree (install, update, etc.) will link workspaces into the node_modules folder. - Commands that do other things (test, exec, publish, etc.) will operate on the root project, unless one or more workspaces are specified in the workspace config.This value is not exported to the environment for child processes.