NPM-SET-SCRIPT(1)
β¨ NAME β¨
npm-set-script β set tasks in the scripts section of package.json π
okay bestie, this is the npm-set-script manual page, and it's genuinely one of the most lowkey-useful little commands npm has. let's get into it π«Ά
π Synopsis π
So basically: it's an npm command that lets you create a task in the scripts section of the package.json. that's it, that's the whole vibe. β¨
npm set-script [<script>] [<command>]
Example:
npm set-script start "http-server ."
and then your package.json ends up looking like this:
{
"name": "my-project",
"scripts": {
"start": "http-server .",
"test": "some existing value"
}
}
see how start just... materialized in there? and test kept its existing value untouched? iconic behavior, no notes π¦
βοΈ Configuration βοΈ
heads up: the config descriptions below are autogenerated. the page literally says<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->, then<!-- automatically generated, do not edit manually -->, then<!-- see lib/utils/config/definitions.js -->. so like... don't edit them manually, iykyk π
π§ workspace
- Default: (nothing β it's just blank)
- Type:
String(and yes, it can be set multiple times π)
This one enables running a command in the context of the configured workspaces of the current project, while filtering so it only runs in the workspaces you defined with this config option. very "main character, but only in these specific rooms" energy.
Valid values for the workspace config are either:
- Workspace names
- Path to a workspace directory
- Path to a parent workspace directory (this one will result in selecting all workspaces within that folder)
When it's set for the npm init command, this may be set to the folder of a workspace which does not yet exist β and npm will create the folder and set it up as a brand new workspace within the project. literally manifesting a workspace fr fr π
This value is not exported to the environment for child processes.
<!-- automatically generated, do not edit manually --> <!-- see lib/utils/config/definitions.js --> π
πΈ workspaces
- Default:
null - Type:
nullorBoolean
Set it to true to run the command in the context of all configured workspaces. all of them. every single one. periodt.
Explicitly setting this to false will cause commands like install to ignore workspaces altogether. and when it's not set explicitly, here's the tea:
- Commands that operate on the
node_modulestree (install,update, etc.) will link workspaces into thenode_modulesfolder. - Commands that do other things (
test,exec,publish, etc.) will operate on the root project, unless one or more workspaces are specified in theworkspaceconfig.
This value is not exported to the environment for child processes.
<!-- automatically generated, do not edit manually --> <!-- see lib/utils/config/definitions.js --> π
π include-workspace-root
- Default:
false - Type:
Boolean
Include the workspace root when workspaces are enabled for a command. π
When it's false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces β and not on the root project. so the root gets left on read, basically. π
<!-- automatically generated, do not edit manually --> <!-- see lib/utils/config/definitions.js --> π
and that's the end of the autogenerated block, btw β the page closes it with <!-- AUTOGENERATED CONFIG DESCRIPTIONS END --> β¨
π See Also π
npm help run-scriptnpm help installnpm help testnpm help start
okay so the footer of this page was literally just undefined NaN with NPM-SET-SCRIPT(1) on the side, which is... a whole mood honestly, the manpage said "no thoughts, head empty" π but anyway, this was the npm-set-script page from the npm manual, dated undefined NaN, and you absolutely ate reading all of it. slay. go set a script. πβ¨π
π¦ where this page comes from
- ubuntu jammy: npm 8.5.1~ds-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms