I am working on an Angular project where we frequently update our internal libraries hosted on Gitea. Recently, we encountered an issue where a library (lenna-class) was updated on Gitea without changing its version number. Another library (lenna-accounting) depends on this updated lenna-class library. When running npm install, we get the following error message:
seems to be corrupted. trying again
We want to force reinstall specific dependencies from Gitea (lenna-class, lenna-vex-theme, lenna-common, lenna-accounting) without deleting the package-lock.json file to avoid issues with other dependencies.
Cleaning npm cache and removing node_modules:
npm cache clean --force rm -rf node_modules npm install
This works but it is a bit heavy-handed and time-consuming as it affects all dependencies.
Using a script to automate the process:
Created a script to delete specific dependencies and reinstall:
#!/bin/bash npm cache clean --force find node_modules -name '@lenna-web' -type d -exec rm -rf {} + npm install
I don’t know if using batch is recommended, as I have been looking for a way to do it in npm and git. Currently, we update the libraries daily, but the intention is to update the library version once a month.