Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install [package] removing packages

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?

like image 918
Michael Nyarach Avatar asked Feb 17 '18 13:02

Michael Nyarach


People also ask

How do I prevent npm install from removing packages?

Using the --no-save will tell npm not to remove the package from your package. json , npm-shrinkwrap. json , or package-lock. json files.

Does npm install remove unused packages?

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.

What is uninstall npm package?

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.

Does npm install install all packages?

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 .


1 Answers

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.

like image 113
isherwood Avatar answered Sep 28 '22 19:09

isherwood