The requested module '@polkadot/api' does not provide an export named 'ApiPromise'
See original GitHub issueHi 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:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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)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.