Is there a simple way to reinstall all packages that my app depends on (i.e. they are in my apps node_modules folder)?
问题:
回答1:
The easiest way that I can see is delete node_modules
folder and execute npm install
.
回答2:
Right way is to execute npm update
. It's a really powerful command, it updates the missing packages and also checks if a newer version of package alreaddy installed can be used.
Read Intro to NPM to understand what you can do with npm.
回答3:
Most of the time I use the following command to achieve a complete reinstall of all the node modules (be sure you are in the project folder).
rm -rf node_modules && npm install
You can also run npm cache clean
after removing the node_modules
folder to be sure there aren't any cached dependencies.
回答4:
npm
updated the install CLI command and added the --force
flag
The -f
or --force
argument will force npm
to fetch remote resources even if a local copy exists on disk.
npm install
回答5:
You can use the reinstall module found in npm.
After installing it, you can use the following command:
reinstall
The only difference with manually removing node_modules
folder and making npm install
is that this command automatically clear npm's cache. So, you can get three steps in one command.