question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The requested module '@polkadot/api' does not provide an export named 'ApiPromise'

See original GitHub issue

Hi everyone,

I ran this code on my PC,

import { ApiPromise } from '@polkadot/api';

async function createApi() {
    const api = await ApiPromise.create();
    return api;
}

const api = createApi()

As instructed by your docs, and I got this error in the first line:

The requested module ‘@polkadot/api’ does not provide an export named ‘ApiPromise’

Am I doing something wrong, or is there a bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jacogrcommented, Oct 15, 2020

It is exported, see here - https://github.com/polkadot-js/api/blob/master/packages/api/src/index.ts#L13

(And it def used that way in projects that i know of, see e.g. https://github.com/w3f/faucet-bot/blob/master/src/server/actions.js#L1

So not sure why it would fail in your case. (You can also do import ApiPromise from '@polkadot/api/promise'; as a direct import, but while that may mask the above should just work)

0reactions
polkadot-js-botcommented, Jun 3, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to import - @polkadot/api · Issue #232 · ije/esm.sh
Failing module GitHub: ... import { ApiPromise, WsProvider } from "https://esm.sh/@polkadot/api"; Error message After running deno r...
Read more >
"The requested module ' does not provide an export named ...
You've confirmed that the package.json in the module's folder doesn't have "type": "module" in it. That's the issue. It's using the older ...
Read more >
Typescript errors when using @polkadot/api
WsProvider("wss://westend-rpc.polkadot.io"); export const client = Polkadot.ApiPromise.create({ provider }); // TODO: use the client to do ...
Read more >
The requested module does not provide an export named ...
The error "The requested module does not provide an export named" occurs when mixing up default and named ES6 module imports and exports....
Read more >
TS type generation
By the @polkadot/types convention, match the export names with the folders (preferably your runtime module names), the generation scripts will use these names...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found