npm install [package] command is removing other packages and I have to run 'npm install' command to reinstall them which is a tedious task.
All packages are recorded in the package.json and package-lock.json files.
If I npm install [package b], it will install package b but remove package a. This occurs vice versa with other packages.
I always have to run 'npm install' to return all removed packages so that now 'packages a and b' exist in the node_modules as intended.
Is this normal procedure for adding packages? Or is there a way I can avoid using 'npm intall' after adding a new package?
Using the --no-save will tell npm not to remove the package from your package. json , npm-shrinkwrap. json , or package-lock. json files.
From npm help prune : This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed. Extraneous packages are packages that are not listed on the parent package's dependencies list.
This uninstalls a package, completely removing everything npm installed on its behalf. It also removes the package from the dependencies , devDependencies , optionalDependencies , and peerDependencies objects in your package. json . Further, if you have an npm-shrinkwrap. json or package-lock.
Install the dependencies to the local node_modules folder. In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package. By default, npm install will install all modules listed as dependencies in package.json .
There was a pruning bug in NPM 5.7 which was resolved not long after this question was posted.
https://github.com/npm/npm/issues/17379
It's apparently resolved as of 5.7.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With