Npm-rebuild

日常开发中 经常遇见npm install失败后再怎么install都不成功问题,在那儿install磨叽半天 么得结果,有一天队友上来一个命令教做人了,那就是npm rebuild。那这样就得来看rebuild是什么操作了。 使用:

npm rebuild [[@scope/name]...]

官方是这样说的:

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.

意思就是rebuild命令其实是在相应的目录运行了一下build命令(这不废话么,re-xxx不就是重复做xxx事么)。当你安装了新版本的node时,必须重新编译C++依赖。

所以最常见的场景是切换node版本时。

参考: npm-rebuild

Last updated

Was this helpful?