'why i can't run command "npm update" in my ionic project?

I can't run command npm update or npm install in my ionic project. this is an error that I get.

enter image description here

and here is my "ionic info"

enter image description here



Solution 1:[1]

..... This kind of stuff happens exactly when you continuously remove package-lock.json in order to update some packages, you never... ever... delete package-lock.json, unless the project is very new and small, it's always the last solution because it can cause exactly what you are facing multiplied by 100. It has lock in name because it has to be fixed, because it holds the exact versioning of your dependency tree. you cannot recreate it, because in order to recreate it you have to use npm install and it may not install dependency tree as it should!. That is why you should use npm ci instead of npm install when generating node_modules, because npm ci fires error if there is no package-lock.json checks package syncronization betwen package-lock.json and package.json, removes old version of node_modules, checks dependency version mismatches, and a lot more...

Now, you should execute the command with --force or --legacy-peer-deps as recommended, and pray that works, if it works you should have in mind that this is a temporary solution, what legacy-peer-deps does is tell npm to ignore dependency conflict and continue instalation. This can also happen, because of some deprecated package, you should check the docs for the package in question. If it doesn't work, try downgrading node.js to 15, but this would also be temporary solution. The proper solution is to manually fix the dependency conflict

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