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