'Corrupted file - .xml2js.DELETE/package,json in node_modules within an Angular project
Errors began after updating to Angular-Cli V10.1.0.
Initial problems I encountered:
- The
ng
command was not working. I found that core dependencies were missing:npm WARN @angular/[email protected] requires a peer of @angular/common@^9.0.0 but none is installed. You must install peer dependencies yourself.
I Tried:
- Installing dependencies manually.
- Uninstalling the angular-cli globally, clearing the cache with --force, rebooting and reinstalling.
- Downloading latest NodeJs, updating npm using
npm update
as well as Angular:ng update
. - Deleting:
package.lock.json
;package.json
;node_modules
I could not delete node_modules:
- A folder:
.xml2js.DELETE
has apackage.json
file that can't be opened in my IDE or by Windows. - I believe it's this file that's preventing me from running
npm install
Solution 1:[1]
EUREKA - Problem Solved!
Steps I took which fixed the issue:
- Open
Powershell
as administrator - Run
chkdsk /f
- Delete
node_modules
- run
npm install
Solution 2:[2]
I think if you are able to successfully delete your entire node_modules folder a simple npm install
will fix your issue.
- Close all programs that could possible touching the file and attempt to delete it.
- Attempt to delete it using the cmd line. If you are not already I suggest you use a cmd prompt like Cmder which will give you some of the linux cmd prompt tools in windows. Then try
rm -rf node_modules
from the correct directory. - If both of those don't work restart your computer, and attempt 1 & 2 again.
- If none of those work boot into safe mode and once again attempt to remove the files.
You can go down a further rabbit hole to figure out how to delete that file but if you are in a time crunch you could just copy your entire project (minus the node_modules) to a new folder. Delete the package.lock.json and then npm install
Solution 3:[3]
Using PowerShell in admin mode to run chkdsk /f
worked for me.
I also had to restart my PC.
Then SHIFT
+ DEL
the node_modules directory.
Worked like a piece of cake!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rafael Zasas |
Solution 2 | Eric S |
Solution 3 |