Skip to content

Commit 5142735

Browse files
authoredOct 18, 2023
docs: update npm build description (#6894)
1 parent 92cd4ad commit 5142735

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed
 

‎docs/lib/content/commands/npm-rebuild.md

+23-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,29 @@ description: Rebuild a package
1010

1111
### Description
1212

13-
This command runs the `npm build` command on the matched folders. This is
14-
useful when you install a new version of node, and must recompile all your
15-
C++ addons with the new binary. It is also useful when installing with
16-
`--ignore-scripts` and `--no-bin-links`, to explicitly choose which
17-
packages to build and/or link bins.
18-
19-
If one or more package specs are provided, then only packages with a
20-
name and version matching one of the specifiers will be rebuilt.
13+
This command does the following:
14+
15+
1. Execute lifecycle scripts (`preinstall`, `install`, `postinstall`, `prepare`)
16+
2. Links bins depending on whether bin links are enabled
17+
18+
This command is particularly useful in scenarios including but not limited to:
19+
20+
1. Installing a new version of **node.js**, where you need to recompile all your C++ add-ons with the updated binary.
21+
2. Installing with `--ignore-scripts` and `--no-bin-links`, to explicitly choose which packages to build and/or link bins.
22+
23+
If one or more package specs are provided, then only packages with a name and version matching one of the specifiers will be rebuilt.
24+
25+
Usually, you should not need to run `npm rebuild` as it is already done for you as part of npm install (unless you suppressed these steps with `--ignore-scripts` or `--no-bin-links`).
26+
27+
If there is a `binding.gyp` file in the root of your package, then npm will use a default install hook:
28+
29+
```
30+
"scripts": {
31+
"install": "node-gyp rebuild"
32+
}
33+
```
34+
35+
This default behavior is suppressed if the `package.json` has its own `install` or `preinstall` scripts. It is also suppressed if the package specifies `"gypfile": false`
2136

2237
### Configuration
2338

0 commit comments

Comments
 (0)
Please sign in to comment.