In the projects where there is the archive package.json
, besides the Uninstall already mentioned in the previous answer, you can use the command:
node prune
Simply edit the file package.json
so that it contains only the dependencies that you use and runs the command that it will delete all packages that are in the node_modules
and which you do not refer to in package.json
.
It is also recommended that package.json
you put in the script of postinstall the command npm prune
so that after a version update for example, packages not used anymore will be removed.
Example of package.json
with script of postinstall:
{
"name": "teste",
"version": "1.0.0",
"description": "Teste",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "npm prune"
},
"author": "bigous",
"license": "ISC",
"dependencies": {
"luaparse": "^0.2.1"
}
}
In this example, any package, except the [email protected]
, will be removed from node_modules
with the command node prune
or after a npm install
no more parameters.
I don’t know if it solves your problem, but select the folders of the packages and delete, delete the packages as well.
– Jonas Martins