W
Wasp-langā€¢4w ago
pavelksg

Cannot import external module @covalenthq/client-sdk

Could you please help me figure out this error:
[ Server!] import { GoldRushClient } from '@covalenthq/client-sdk';
[ Server!] ^^^^^^^^^^^^^^
[ Server!] SyntaxError: The requested module '@covalenthq/client-sdk' does not provide an export named 'GoldRushClient'
[ Server!] at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
[ Server!] at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
[ Server!]
[ Server!] import { GoldRushClient } from '@covalenthq/client-sdk';
[ Server!] ^^^^^^^^^^^^^^
[ Server!] SyntaxError: The requested module '@covalenthq/client-sdk' does not provide an export named 'GoldRushClient'
[ Server!] at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
[ Server!] at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
[ Server!]
This happens in fresh wasp 0.14 app with TypeScript. I added "@covalenthq/client-sdk": "^2.1.1" into my package.json, and then added import { GoldRushClient } from "@covalenthq/client-sdk"; into one of the custom actions. After I run wasp start, I'm getting error above
9 Replies
kapa.ai
kapa.aiā€¢4w ago
Hi @pavelksg. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The error message suggests that the module '@covalenthq/client-sdk' does not provide an export named 'GoldRushClient'. This could mean that the 'GoldRushClient' is not exported by the '@covalenthq/client-sdk' module, or there might be an issue with how the module is being imported. However, none of the knowledge sources provided mention the '@covalenthq/client-sdk' module or the 'GoldRushClient'. Therefore, I can't provide a specific solution based on the provided knowledge sources. I would recommend checking the documentation of the '@covalenthq/client-sdk' module to ensure that 'GoldRushClient' is a valid export. If it is, there might be an issue with your project setup or the way you're trying to import the module. You might also find it helpful to look at the Wasp documentation (https://wasp-lang.dev/docs) or ask for help in the Wasp community (https://discord.com/invite/rzdnErX). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @pavelksg, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
pavelksg
pavelksgā€¢4w ago
Here is what I see in node_modules/@covalenthq/client-sdk/dist/esm/index.js
class GoldRushClient { constructor(apiKey, settings = {}) { this.userAgent = com.covalenthq.sdk.typescript/${version}; const validKey = isValidApiKey(apiKey); if (!validKey) { throw { data: null, error: true, error_code: 401, error_message: "Invalid or missing API key (sign up at https://goldrush.dev/platform/apikey)", }; } const execution = new Execution(settings, { Authorization: Bearer ${apiKey}, "X-Requested-With": settings.source ? ${settings.source} (${this.userAgent}) : this.userAgent, }); this.BalanceService = new BalanceService(execution); this.BaseService = new BaseService(execution); this.NftService = new NftService(execution); this.PricingService = new PricingService(execution); this.SecurityService = new SecurityService(execution); this.TransactionService = new TransactionService(execution); } }
class GoldRushClient { constructor(apiKey, settings = {}) { this.userAgent = com.covalenthq.sdk.typescript/${version}; const validKey = isValidApiKey(apiKey); if (!validKey) { throw { data: null, error: true, error_code: 401, error_message: "Invalid or missing API key (sign up at https://goldrush.dev/platform/apikey)", }; } const execution = new Execution(settings, { Authorization: Bearer ${apiKey}, "X-Requested-With": settings.source ? ${settings.source} (${this.userAgent}) : this.userAgent, }); this.BalanceService = new BalanceService(execution); this.BaseService = new BaseService(execution); this.NftService = new NftService(execution); this.PricingService = new PricingService(execution); this.SecurityService = new SecurityService(execution); this.TransactionService = new TransactionService(execution); } }
and then this at the bottom: export { ChainID, ChainName, GoldRushClient, bigIntParser, calculatePrettyBalance, isValidApiKey, prettifyCurrency };
Filip
Filipā€¢4w ago
Very strange, let me try to install it I reproduced it, and it seems to be an issue with this specific package. I'll get back to it in a minute, let me just answer other users first Couldn't figure this out today. Strangely enough, this is the only package that's causing problems, but it works when building, and in the IDE, and only fails in runtime. @pavelksg Which version of Node are you using? @miho, could this have something to do with server bundling? Because my IDE says everything is fine (and autocompletes it), both when opening the user project and the .wasp/out/server project. I tried it with Node 18.x and node 20.x, same problem. Perhaps you'll know what's up from the top of your head
pavelksg
pavelksgā€¢4w ago
Thanks for looking into it! Iā€™m using 18.18. Also tried the weirdest suggestions from GPT-4o on what I can change in all configs including Vite, but nothing helped I just confirmed it works in a clean, pure TypeScript with target: "esnext" in tsconfig.json. index.ts:
import { GoldRushClient } from "@covalenthq/client-sdk";

const ApiServices = async () => {
const client = new GoldRushClient("some api key");
try {
const resp = await client.BaseService.getAddressActivity("some address");
console.log(resp.data);
} catch (error) {
console.error(error);
}
}

(async () => {
await ApiServices();
})();
import { GoldRushClient } from "@covalenthq/client-sdk";

const ApiServices = async () => {
const client = new GoldRushClient("some api key");
try {
const resp = await client.BaseService.getAddressActivity("some address");
console.log(resp.data);
} catch (error) {
console.error(error);
}
}

(async () => {
await ApiServices();
})();
package.json:
{
"name": "goldrush-tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^22.7.4",
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
},
"dependencies": {
"@covalenthq/client-sdk": "^2.1.1"
}
}
{
"name": "goldrush-tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^22.7.4",
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
},
"dependencies": {
"@covalenthq/client-sdk": "^2.1.1"
}
}
However I am able to break it by changing to "module": "esnext", in tsconfig.json here is an example repository that seem to be including this modules and should be working fine: https://github.com/covalenthq/goldrush-kit/blob/main/package.json
MEE6
MEE6ā€¢4w ago
Wohooo @pavelksg, you just became a Waspeteer level 1!
Filip
Filipā€¢4w ago
Thanks! I tried that too, it's not the package itself, it's some kind of combination of our build process and the package. I'll try to look into it some more today. Let's also see what @miho has to say. Perhaps he has an idea
miho
mihoā€¢4w ago
Lemme try it and I'll report back šŸ™‚
miho
mihoā€¢4w ago
Running it with my Typescript starter produces the same error for me :/ I'll try to see what can I find out
No description
miho
mihoā€¢4w ago
The way I got it working:
import covalent from '@covalenthq/client-sdk';

const ApiServices = async () => {
const client = new covalent.GoldRushClient('some api key');
try {
const resp = await client.BaseService.getAddressActivity('some address');
console.log(resp.data);
} catch (error) {
console.error(error);
}
};

(async () => {
await ApiServices();
})();

// Handle promise rejection
process.on('unhandledRejection', (error) => {
console.error('unhandledRejection', error);
});
import covalent from '@covalenthq/client-sdk';

const ApiServices = async () => {
const client = new covalent.GoldRushClient('some api key');
try {
const resp = await client.BaseService.getAddressActivity('some address');
console.log(resp.data);
} catch (error) {
console.error(error);
}
};

(async () => {
await ApiServices();
})();

// Handle promise rejection
process.on('unhandledRejection', (error) => {
console.error('unhandledRejection', error);
});
I get Invalid or missing API key (sign up at https://goldrush.dev/platform/apikey) which is expected. This is super weird for me. It should work in both cases, but something is off with their / our setup and something doesn't align as we expect. We'll investigate further.
Want results from more Discord servers?
Add your server