Corrupted file - .xml2js.DELETE/package,json in node_modules within an Angular project

700 views Asked by At

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 usingnpm 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 a package.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
3

There are 3 answers

0
Rafael Zasas On BEST ANSWER

EUREKA - Problem Solved!

Steps I took which fixed the issue:

  • Open Powershell as administrator
  • Run chkdsk /f
  • Delete node_modules
  • run npm install
1
MSFTMish On

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!

0
Eric S On

I think if you are able to successfully delete your entire node_modules folder a simple npm install will fix your issue.

  1. Close all programs that could possible touching the file and attempt to delete it.
  2. 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.
  3. If both of those don't work restart your computer, and attempt 1 & 2 again.
  4. 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