-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Add better error message when lockfile is malformed #6997
base: latest
Are you sure you want to change the base?
fix: Add better error message when lockfile is malformed #6997
Conversation
I would like to have added a test case for this but I have never contributed to this repo before and don't know how to mock the relevant areas. |
Can you go into more detail about how you fix up the lockfile? |
sure, I found I was in the state that the
but the corresponding entry with key |
Is this the kind of thing we should be manually fixing up instead? |
That would be even better, but I don't think I know enough about arborist to make that change. |
We can start by building on your own reproduction case, which appears to be a good one. If I'm understanding correctly you have a workspace that's properly linked into If that's really the case then once you fix the lockfile and run |
Or is it the other way around, where the link still exists but the underlying package was moved? |
|
And the link from the top level |
So in the broken state where there is a entry in the lock that looks like this "node_modules/@my-scope/my-package": {
"resolved": "packages/some-folder/my-package",
"link": true
}, Does |
No that entry in the lock file doesn't exist. And the symlink also doesn't exist Which is why I think I see the initial error:
|
Ok, sorry I'm confused as to what the error state is. Is there a reproducible way to trigger it? |
Yeah, let me try and make a repo |
@wraithgar Here is the demo repo https://github.com/Nokel81/npm-cli-error-case |
That is a very succinct reproduction case, thank you. How did you get the repo into that state? |
To make the demo I manually modified the |
Sometimes when I am working with a monorepo of many workspaces with intermittencies I encounter the following error:
Which isn't very actionable. It also isn't very actionable with I add the
--verbose
option. All that does is point to@npmcli/arborist/lib/arborist/load-virtual.js:297:30
.Having added some logging manually I have been always able to fix up the lock file merely but removing the offending entry and then running
npm install
again.