question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Make `ionic repair` only remove `package-lock.json` with an option

See original GitHub issue

Currently ionic repair will:

  1. rm -rf node_modules/ plugins/ platforms/
  2. rm package-lock.json
  3. npm i
  4. re-add the platforms

Or some variant thereof.

The problem I have with it is the removal of the package-lock.json file, which I believe should only be done under extreme circumstances where-as the rebuilding of plugins/ and platforms/ is basically always safe and is often necessary when upgrading plugins due to Cordova’s aggressive caching.

We have run into issues with some enterprise customers where they have used ionic repair in order to fix issues with the plugins only to also accidentally upgrade all of their dependencies at the same time (luckily, in most cases they were using ~, but a few were using ^, which we have coached them not to do, but still…

Given that the most common use case here is the plugins having gotten out of whack, I believe the removal of the package-lock.json file is a bit too aggressive with the exception of very odd cases, and thus should be controlled via an argument to the command.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
imhoffdcommented, Jun 25, 2019

I took it to mean only work with Cordova.

  1. rm -rf plugins/ platforms/
  2. cordova prepare
0reactions
bryplanocommented, Jun 25, 2019

Ah I see. So there would not be any option for node_modules to be deleted & reinstalled because

Since the lock file represents a node_modules installation 1:1, people would rm -rf node_modules && npm install with no change in behavior

If that’s the case then 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deleting `package-lock.json` to Resolve Conflicts quickly
The last line in this answer is the key. After pulling and seeing that the merge conflict is only in the package-lock.json file(s),...
Read more >
package-lock.json - npm Docs
package -lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json . It describes the exact ...
Read more >
Fixing security vulnerabilities in npm dependencies in less ...
So a better solution here would be to only delete the lines corresponding to the vulnerable package in your package-lock.json(or yarn.lock) file.
Read more >
Solving conflicts in package-lock.json - TkDodo's blog
The conflicts in package.json are usually easily solved (if there even are any), so I think it is tempting to just delete package-lock.json...
Read more >
How should you pin dependencies and why? – The Guild
Both yarn and recent npm versions allow you to create a lock file. This allows you to lock each and every package you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found