1

I have this in my single Javascript client.js that I am going to run with node. It's just the single file; was not created as a node project. (no npm init):

const { WsProvider, ApiPromise } = require('@polkadot/api');
const { ContractPromise } = require('@polkadot/api-contract');

When I attemp to run it, I get (just a sample of a long list):

@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 10.1.1      node_modules/@polkadot/api/node_modules/@polkadot/util/cjs
        cjs 10.1.2      node_modules/@polkadot/api-contract/node_modules/@polkadot/util/cjs
@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.14.1      node_modules/@polkadot/api/node_modules/@polkadot/types/cjs
        cjs 9.0.1       node_modules/@polkadot/api-contract/node_modules/@polkadot/types/cjs

I originally installed all npm packages "globally" ($HOME/.nvm/versions/node/blahblah...) because I didn't want a bunch of repeated node_modules all over the place.

And I did a symbolic link from the (above) global location to wherever my client.js was.

I also didn't want to have to mess with package.json etc.. just keep things as simple as possible. One file.

And it all worked until now.

2 Answers 2

3

I had to go ahead and do an npm init in the location of my client.js, then npm install @polkadot/api@latest @polkadot/api-contract@latest in same location, then npm dedupe @polkadot/api@latest @polkadot/api-contract@latest.

Now no conflicts.

1

I believe you originally had different versions of each package. All variants of @polkadot/<package> typically have the same version. @latest forced all of those to be the same and therefore no longer collide

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.