node.js “npm 安装”和“npm 重建”有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48473984/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is difference between 'npm install' and 'npm rebuild'?
提问by Pushpendra Kumar
I upgrade my node version from v7.1.0 to v9.4.0. After this m trying to run my server then I get this.
我将节点版本从 v7.1.0 升级到 v9.4.0。在此之后我尝试运行我的服务器然后我得到了这个。
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 59. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
then I know about npm rebuild. I run both command npm rebuildand npm install. It fixed after run npm rebuildbut I do not understand what it does.
Please explain about npm rebuild
然后我就知道了npm rebuild。我同时运行 commandnpm rebuild和npm install. 它在运行后修复, npm rebuild但我不明白它的作用。请解释一下npm rebuild
thank you
谢谢你
回答by Gaurav Paliwal
npm install: It is obvious that npm installis used to install packages using the package.jsonfile, this command also installs the other packages on which the packages (in package.json) are dependent.
On the backside, this command uses the npm buildwhich helps to build the packages you are installing.
npm install:很明显npm install是用来安装使用package.json文件的包,这个命令还会安装包(in package.json)所依赖的其他包。在背面,此命令使用npm build帮助构建您正在安装的软件包。
npm rebuild: As the name rebuild, this command again builds the packages, used only when you upgrade the node version and must recompile all your C++ addons with the new binary.
npm rebuild:作为名称重建,此命令再次构建包,仅在升级节点版本时使用,并且必须使用新的二进制文件重新编译所有 C++ 插件。

