yarn
yarn copied to clipboard
error Failed to import from package-lock.json, source file(s) corrupted
I was trying to use your yarn import
command to generate yarn.lock
file in npm package, the package lock does exist. package-lock.json
$ yarn import
yarn import v1.22.19
info found npm package-lock.json, converting to yarn.lock
error Failed to import from package-lock.json, source file(s) corrupted
info Visit https://yarnpkg.com/en/docs/cli/import for documentation about this command.
I've reinstalled the dependencies. still I encounter the same problem.
Also running into this
Just tried to use yarn import
and got into the same problem here.
any solutions ?
Not the greatest answer but we ended up switching to pnpm
and haven't looked back ;-)
Same issue. Basically you can't properly migrate from npm to yarn at the moment because lock file import doesn't work. If you just run yarn install
it will install different dependencies.
Not a huge deal because we have semver but still annoying.
Deleting package-lock.json works for me. It now says: "info creating yarn.lock from local node_modules folder"
Which is fine...
I found out that this is caused by a dependency:
"@isaacs/cliui@^8.0.2":
version "8.0.2"
resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550"
integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==
dependencies:
string-width "^5.1.2"
string-width-cjs "npm:string-width@^4.2.0"
strip-ansi "^7.0.1"
strip-ansi-cjs "npm:strip-ansi@^6.0.1"
wrap-ansi "^8.1.0"
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
"license": "ISC",
"dependencies": {
"string-width": "^5.1.2",
"string-width-cjs": "npm:string-width@^4.2.0",
"strip-ansi": "^7.0.1",
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
"wrap-ansi": "^8.1.0",
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
},
"engines": {
"node": ">=12"
}
},
specifically the version numbers which prefix with npm:
(e.g.: npm:string-width@^4.2.0
).
Unfortunately no resolution - anyone else run in to this?
Funny enough, the resolution was resolutions.
In your package.json
, add a resolutions field:
"resolutions": {
"string-width": "^5.1.2",
"strip-ansi": "^7.0.1",
"wrap-ansi": "^8.1.0"
}
Your problem may not be with string-width
, strip-ansi
and wrap-ansi
- but the solution may be to search your package-lock.json
and find where npm:
is being used and write resolutions for it.
@bashaus I had the same three packages prefixed with npm:
but adding them to resolutions didn't help. yarn import
still fails by saying that package-lock.json is corrupt.