3

I am still learning TypeScript and I have some code that is working, but it returns a lot of messages about multiple versions of modules and conflicting packages. What is the best way to fix these messages? Also, based on my readings yarn supposedly automatically dedupes when you use yarn add, but that is not my experience based on these messages. I know the package.json lists the dependencies and version numbers, but I don't know enough to know how to modify that file to fix this problem. Any and all suggestions are appreciated.

@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 9.1.1       node_modules/@polkadot/api/node_modules/@polkadot/util/cjs
        cjs 9.1.1       node_modules/@polkadot/types/node_modules/@polkadot/util/cjs
@polkadot/util-crypto has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 9.1.1       node_modules/@polkadot/api/node_modules/@polkadot/util-crypto/cjs
        cjs 9.1.1       node_modules/@polkadot/types/node_modules/@polkadot/util-crypto/cjs
@polkadot/wasm-crypto has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 6.0.1       node_modules/@polkadot/api/node_modules/@polkadot/wasm-crypto/cjs
        cjs 6.0.1       node_modules/@polkadot/types/node_modules/@polkadot/wasm-crypto/cjs
@polkadot/wasm-crypto-wasm has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 6.0.1       node_modules/@polkadot/api/node_modules/@polkadot/wasm-crypto-wasm/cjs
        cjs 6.0.1       node_modules/@polkadot/types/node_modules/@polkadot/wasm-crypto-wasm/cjs
@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 9.1.1       node_modules/@polkadot/api/node_modules/@polkadot/util/cjs
        cjs 9.1.1       node_modules/@polkadot/types/node_modules/@polkadot/util/cjs
        cjs 9.1.1       node_modules/@polkadot/types-known/node_modules/@polkadot/util/cjs
@polkadot/types-create has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 8.3.1       node_modules/@polkadot/types/node_modules/@polkadot/types-create/cjs
        cjs 8.3.1       node_modules/@polkadot/types-known/node_modules/@polkadot/types-create/cjs
@polkadot/types-codec has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 8.3.1       node_modules/@polkadot/types/node_modules/@polkadot/types-codec/cjs
        cjs 8.3.1       node_modules/@polkadot/types-known/node_modules/@polkadot/types-codec/cjs
@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 9.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/api/node_modules/@polkadot/util/cjs
        cjs 9.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/node_modules/@polkadot/util/cjs
        cjs 9.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types-known/node_modules/@polkadot/util/cjs
        cjs 8.7.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/util
@polkadot/rpc-core has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 8.3.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/api/node_modules/@polkadot/rpc-core/cjs
        cjs 7.15.1      /Users/rogerbos/subquery/pulse/node_modules/@polkadot/rpc-core
@polkadot/types has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 8.3.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/cjs
        cjs 7.15.1      /Users/rogerbos/subquery/pulse/node_modules/@polkadot/rpc-core/node_modules/@polkadot/types
@polkadot/types-create has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 8.3.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/node_modules/@polkadot/types-create/cjs
        cjs 8.3.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types-known/node_modules/@polkadot/types-create/cjs
        cjs 7.15.1      /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types-create
@polkadot/types-codec has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 8.3.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/node_modules/@polkadot/types-codec/cjs
        cjs 8.3.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types-known/node_modules/@polkadot/types-codec/cjs
        cjs 7.15.1      /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types-codec
@polkadot/util-crypto has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 9.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/api/node_modules/@polkadot/util-crypto/cjs
        cjs 9.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/node_modules/@polkadot/util-crypto/cjs
        cjs 8.7.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/util-crypto
@polkadot/wasm-crypto has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 6.0.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/api/node_modules/@polkadot/wasm-crypto/cjs
        cjs 6.0.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/node_modules/@polkadot/wasm-crypto/cjs
        cjs 5.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/wasm-crypto
@polkadot/wasm-crypto-wasm has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 6.0.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/api/node_modules/@polkadot/wasm-crypto-wasm/cjs
        cjs 6.0.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/types/node_modules/@polkadot/wasm-crypto-wasm/cjs
        cjs 5.1.1       /Users/rogerbos/subquery/pulse/node_modules/@polkadot/wasm-crypto-wasm
karura
2
  • As the message suggests, run yarn dedupe or npm dedupe (depending on your package manager)
    – Jaco
    Commented May 5, 2022 at 5:17
  • Does yarn dedupe actually work for other people? when I try it I get an error message that it isn't necessary (and it doesn't do anything): rogerbos@rogers-mbp pulse % yarn dedupe yarn dedupe v1.22.18 warning ../../package.json: No license field error The dedupe command isn't necessary. `yarn install` will already dedupe. info Visit https://yarnpkg.com/en/docs/cli/dedupe for documentation about this command. Commented May 5, 2022 at 13:33

2 Answers 2

4

Set your polkadot resolutions to the same values as polkadot apps and you should be good to go. This is what they're currently set to:

  "resolutions": {
    "@polkadot/api": "^8.3.1",
    "@polkadot/api-augment": "^8.3.1",
    "@polkadot/api-base": "^8.3.1",
    "@polkadot/api-contract": "^8.3.1",
    "@polkadot/api-derive": "^8.3.1",
    "@polkadot/hw-ledger": "^9.1.1",
    "@polkadot/keyring": "^9.1.1",
    "@polkadot/networks": "^9.1.1",
    "@polkadot/phishing": "^0.12.1",
    "@polkadot/rpc-augment": "^8.3.1",
    "@polkadot/rpc-core": "^8.3.1",
    "@polkadot/rpc-provider": "^8.3.1",
    "@polkadot/types": "^8.3.1",
    "@polkadot/types-augment": "^8.3.1",
    "@polkadot/types-codec": "^8.3.1",
    "@polkadot/types-create": "^8.3.1",
    "@polkadot/types-known": "^8.3.1",
    "@polkadot/types-support": "^8.3.1",
    "@polkadot/util": "^9.1.1",
    "@polkadot/util-crypto": "^9.1.1",
    "@polkadot/wasm-crypto": "^6.0.1",
    "typescript": "^4.6.4"
  }

If you still hit issues after this, try removing the hats (^) from the resolutions to force a specific version. The ^ indicates that you are willing to take further increments but not move to a new major version

^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0

Source

1
  • 1
    Great suggestion. I didn't want to mess with the resolutions myself because I don't know which version to use, but the suggestion to get them from Polkadot was helpful. Note that I had to delete the node_modules and re-install to resolve other errors. Thanks! Commented May 6, 2022 at 13:06
0

The message does suggest npm dedupe or yarn dedupe. In my experience the package managers don't apply it consistently, especially when upgrading.

There does seem to be an issue with your deps however, some seem to require 9.1.1 and other 8.7.1 of the util dependencies.

In the worst-case, when using yarn, you can always resort to resolutions, but that would assume that you really have the latest of all required. (Which as per the point above doesn't seem to be the case here)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.