Skip to content
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

Error "inconsistent snapshot" #2

Open
qq253498229 opened this issue Oct 31, 2023 · 4 comments
Open

Error "inconsistent snapshot" #2

qq253498229 opened this issue Oct 31, 2023 · 4 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@qq253498229
Copy link

I'm using @antongolub/lockfile in my application to parse some dependencies and their sub-dependencies.
When I execute the analyze function, it throws the following exception:

Uncaught Error: inconsistent snapshot: string-width ^4.1.0
(anonymous function) 	analyze.ts:65
walk                 	analyze.ts:62
walk                 	analyze.ts:76
walk                 	analyze.ts:76
walk                 	analyze.ts:76
(anonymous function) 	analyze.ts:123
analyze              	analyze.ts:123
getDependencyTree    	build.mjs:61
copyDependencies     	build.mjs:69
(anonymous function) 	build.mjs:74
run                  	module_job:194
Async call from await
runMainESM           	run_main:60
executeUserEntryPoint	run_main:83
(anonymous function) 	run_main_module:23

Here is my code:

const dependencies = [
    'zip-lib'
]

function getDependencyTree() {

    const lf = fse.readFileSync('../yarn.lock', 'utf-8')
    const pkg = fse.readFileSync('../package.json', 'utf-8')

    const snapshot = parse(lf, pkg) // Holds JSON-friendly TEntries[]
    const idx = analyze(snapshot)   // An index to represent repo dep graphs
    let tree = idx.tree;
    return Object.keys(tree)
        .filter(s => s.split(',').length > 1 && dependencies.indexOf(s.split(',')[1]) !== -1)
        .map(s => tree[s].chunks[tree[s].chunks.length - 1]);
}

function copyDependencies() {
    let tree = getDependencyTree()
    console.log(1)
}

//copy depts what angular not include
copyDependencies()

@qq253498229
Copy link
Author

Could it be a conflict caused by having two package.json files in the environment at the same time?

@antongolub
Copy link
Owner

antongolub commented Oct 31, 2023

I'm afraid, this kind of aliases is not supported yet.

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
  version "4.2.3"
  resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
  integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
  dependencies:
    emoji-regex "^8.0.0"
    is-fullwidth-code-point "^3.0.0"
    strip-ansi "^6.0.1"
"string-width-cjs@npm:[email protected]": {
    "name": "string-width-cjs@npm:string-width",
    "version": "4.2.3",
    "ranges": [
      "^1.0.2 || 2 || 3 || 4",
      "^4.1.0",
      "^4.2.0",
      "^4.2.0",
      "^4.2.3"
    ],
    "hashes": {
      "sha512": "wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="
    },
"@isaacs/cliui@^8.0.2":
  version "8.0.2"
  resolved "https://registry.npmmirror.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"

@antongolub
Copy link
Owner

antongolub commented Nov 1, 2023

@qq253498229

I added limited aliases support for yarn-classic lockfiles. You can try @antongolub/[email protected] or higher versions

@antongolub antongolub added the enhancement New feature or request label Nov 1, 2023
antongolub added a commit that referenced this issue Nov 1, 2023
antongolub added a commit that referenced this issue Nov 2, 2023
antongolub added a commit that referenced this issue Nov 2, 2023
@antongolub antongolub added the bug Something isn't working label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants