-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(arborist): Add better error message when lockfile is malformed #8268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: latest
Are you sure you want to change the base?
Conversation
aab72e9
to
cc0d28a
Compare
@@ -200,6 +200,13 @@ module.exports = cls => class VirtualLoader extends cls { | |||
const targetPath = resolve(this.path, meta.resolved) | |||
const targetLoc = relpath(this.path, targetPath) | |||
const target = nodes.get(targetLoc) | |||
|
|||
if (!target) { | |||
const err = new Error(`Missing target in lock file: "${targetLoc}" is referenced by "${location}" but does not exist.\nThis is likely due to a damaged lock file. Remove the entry for "${location}" from your lock file and run npm install again.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically we don't suggest folks editing their lockfile manually. Is there a better programmatic way to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wraithgar fair point! I updated it. See what you think 😄
cc0d28a
to
83eb43c
Compare
const err = new Error( | ||
`Missing target in lock file: "${targetLoc}" is referenced by "${location}" but does not exist. | ||
To fix: | ||
1. rm -rf node_modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this overkill? Having node_modules will make this go much faster and keep churn down on the lockfile.
Overrides #6997 with a more standard way of expressing errors in the cli and has a test for it.