0

I got some error when using Polkadot{js} API. what's wrong? should I update the version of package?

import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBigInt, isBn, isFunction, isHex, isNumber, isObject, isString, isU8a, u8aToBn, u8aToNumber } from '@polkadot/util';
                                                                                                                                                                                                               ^^^^^^^^^^^
SyntaxError: The requested module '@polkadot/util' does not provide an export named 'u8aToNumber'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15) {
  page: '/'
}

enter image description here

2
  • I could solve the issue by deleting node_modules and install again
    – Steve
    Feb 13, 2023 at 5:11
  • If deleting your node_modules and installing again worked it was probably a version issue. You can create an answer to your question an mark it as solved
    – Alex Bean
    Feb 13, 2023 at 9:08

2 Answers 2

2

Polkadot-js has a pretty strict dependency tree outline where versions of different @polkadot/* packages need to match the root of @polkadot/api.

For example:

@polkadot/api -> v9.14.1 requires @polkadot/util -> v10.4.1 So if you are using v9.14.1 of the API, any package you consume from the polkadot-js/common (i.e. @polkadot/util-crypto, @polkadot/keyring, etc.) repository should also be v10.4.1.

This will ensure that there is no conflict in package versions and the above error won't happen. Also as a side note, updating to the latest version of each package will ensure they match, as releases will be in sync with each other.

1

all what I had to do was update the version of packages so if you meet this error, plz try to delete node_module and yarn install again

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.