1 ---
2 title: npm-rebuild
3 section: 1
4 description: Rebuild a package
5 github_repo: npm/cli
6 github_branch: release/v9
7 github_path: docs/lib/content/commands/npm-rebuild.md
8 redirect_from:
9 - /cli-documentation/v9/cli-commands/npm-rebuild
10 - /cli-documentation/v9/cli-commands/rebuild
11 - /cli-documentation/v9/commands/npm-rebuild
12 - /cli-documentation/v9/commands/rebuild
13 - /cli-documentation/v9/npm-rebuild
14 - /cli-documentation/v9/rebuild
15 - /cli/v9/cli-commands/npm-rebuild
16 - /cli/v9/cli-commands/rebuild
17 - /cli/v9/commands/rebuild
18 - /cli/v9/npm-rebuild
19 - /cli/v9/rebuild
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm rebuild [<package-spec>] ...]
26
27 alias: rb
28 ```
29
30 ### Description
31
32 This command runs the `npm build` command on the matched folders. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary. It is also useful when installing with `--ignore-scripts` and `--no-bin-links`, to explicitly choose which packages to build and/or link bins.
33
34 If one or more package specs are provided, then only packages with a name and version matching one of the specifiers will be rebuilt.
35
36 ### Configuration
37
38 #### `global`
39
40 - Default: false
41 - Type: Boolean
42
43 Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See [folders](/cli/v9/configuring-npm/folders) for more on the differences in behavior.
44
45 - packages are installed into the `{prefix}/lib/node_modules` folder, instead of the current working directory.
46 - bin files are linked to `{prefix}/bin`
47 - man pages are linked to `{prefix}/share/man`
48
49 #### `bin-links`
50
51 - Default: true
52 - Type: Boolean
53
54 Tells npm to create symlinks (or `.cmd` shims on Windows) for package executables.
55
56 Set to false to have it not do this. This can be used to work around the fact that some file systems don't support symlinks, even on ostensibly Unix systems.
57
58 #### `foreground-scripts`
59
60 - Default: false
61 - Type: Boolean
62
63 Run all build scripts (ie, `preinstall`, `install`, and `postinstall`) scripts for installed packages in the foreground process, sharing standard input, output, and error with the main npm process.
64
65 Note that this will generally make installs run slower, and be much noisier, but can be useful for debugging.
66
67 #### `ignore-scripts`
68
69 - Default: false
70 - Type: Boolean
71
72 If true, npm does not run scripts specified in package.json files.
73
74 Note that commands explicitly intended to run a particular script, such as `npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script` will still run their intended script if `ignore-scripts` is set, but they will _not_ run any pre- or post-scripts.
75
76 #### `workspace`
77
78 - Default:
79 - Type: String (can be set multiple times)
80
81 Enable 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.
82
83 Valid values for the `workspace` config are either:
84
85 - Workspace names
86 - Path to a workspace directory
87 - Path to a parent workspace directory (will result in selecting all workspaces within that folder)
88
89 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.
90
91 This value is not exported to the environment for child processes.
92
93 #### `workspaces`
94
95 - Default: null
96 - Type: null or Boolean
97
98 Set to true to run the command in the context of **all** configured workspaces.
99
100 Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly:
101
102 - Commands that operate on the `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.
103
104 This value is not exported to the environment for child processes.
105
106 #### `include-workspace-root`
107
108 - Default: false
109 - Type: Boolean
110
111 Include the workspace root when workspaces are enabled for a command.
112
113 When 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.
114
115 This value is not exported to the environment for child processes.
116
117 #### `install-links`
118
119 - Default: false
120 - Type: Boolean
121
122 When set file: protocol dependencies will be packed and installed as regular dependencies instead of creating a symlink. This option has no effect on workspaces.
123
124 ### See Also
125
126 - [package spec](/cli/v9/using-npm/package-spec)
127 - [npm install](/cli/v9/commands/npm-install)