2020-12-04 15:51:55 -05:00
|
|
|
---
|
|
|
|
title: npm-set-script
|
|
|
|
section: 1
|
|
|
|
description: Set tasks in the scripts section of package.json
|
|
|
|
---
|
|
|
|
|
|
|
|
### Synopsis
|
2021-04-01 17:27:18 -04:00
|
|
|
An npm command that lets you create a task in the `scripts` section of the `package.json`.
|
2020-12-04 15:51:55 -05:00
|
|
|
|
|
|
|
```bash
|
|
|
|
npm set-script [<script>] [<command>]
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
**Example:**
|
|
|
|
|
|
|
|
* `npm set-script start "http-server ."`
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"name": "my-project",
|
|
|
|
"scripts": {
|
|
|
|
"start": "http-server .",
|
|
|
|
"test": "some existing value"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-04-01 17:27:18 -04:00
|
|
|
### Configuration
|
|
|
|
|
|
|
|
#### workspaces
|
|
|
|
|
|
|
|
Enables workspaces context. Tasks will be created in the `scripts` section
|
|
|
|
of the `package.json` of each workspace.
|
|
|
|
|
|
|
|
#### workspace
|
|
|
|
|
|
|
|
Enables workspaces context and limits creating a task to the
|
|
|
|
`package.json` files of the workspaces given.
|
|
|
|
|
|
|
|
|
2020-12-04 15:51:55 -05:00
|
|
|
### See Also
|
|
|
|
|
|
|
|
* [npm run-script](/commands/npm-run-script)
|
|
|
|
* [npm install](/commands/npm-install)
|
|
|
|
* [npm test](/commands/npm-test)
|
|
|
|
* [npm start](/commands/npm-start)
|