Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between 'npm install' and 'npm rebuild'?

Tags:

node.js

npm

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.

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 rebuild and npm install. It fixed after run npm rebuild but I do not understand what it does. Please explain about npm rebuild

thank you

like image 920
Pushpendra Kumar Avatar asked Jan 27 '18 08:01

Pushpendra Kumar


People also ask

What npm rebuild do?

The npm-rebuild command will run npm build command on the matched folders. This command is particularly useful when you install a new version of node, and you have to recompile all your C++ addons with the new binary. This command opens a package repository page in the browser.

What is the difference between npm install and npm install?

npm install , or npm i , is used to install dependencies: It will install all the dependencies. If you use ^ or ~ when you specify the version of your dependency, npm may not install the exact version you specified. npm install can update your package-lock.

What is the difference between npm install and npm run build?

npm install installs dependencies into the node_modules/ directory, for the node project you're working on. You can call install on another node. js project (module), to install it as a dependency for your project. npm run build does nothing unless you specify what "build" does in your package.

What is the difference between npm install and npm update?

The npm install installs all modules that are listed on package. json file and their dependencies. npm update updates all packages in the node_modules directory and their dependencies.


1 Answers

npm install: It is obvious that npm install is used to install packages using the package.json file, this command also installs the other packages on which the packages (in package.json) are dependent. On the backside, this command uses the npm build which helps to build the packages you are installing.

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.

like image 158
Gaurav Paliwal Avatar answered Oct 09 '22 11:10

Gaurav Paliwal