Issue with @sapphire/plugin-api

Hello, I have installed @sapphire/plugin-api using the following command:
npm i @sapphire/plugin-api
npm i @sapphire/plugin-api
The install went fine, but intellisense is not showing "api" in my ClientOptions, instead I am getting this error:
Object literal may only specify known properties, and 'api' does not exist in type 'ClientOptions'.
Object literal may only specify known properties, and 'api' does not exist in type 'ClientOptions'.
This is my package.json :
{
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "swc src -d dist --config-file config.swcrc",
"start": "npm run build && node dist/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@swc/cli": "^0.1.63",
"@swc/core": "^1.3.102"
},
"dependencies": {
"@prisma/client": "^5.8.1",
"@sapphire/decorators": "^6.0.3",
"@sapphire/framework": "^5.0.6",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-subcommands": "^6.0.2",
"@sapphire/time-utilities": "^1.7.11",
"canvas": "^2.11.2",
"common-tags": "^1.8.2",
"discord.js": "^14.14.1",
"dot-prop": "^6.0.1",
"dotenv": "^16.3.1",
"ms": "^2.1.3",
"node-cron": "^3.0.3",
"prisma": "^5.8.1",
"ws": "^8.16.0"
}
}
{
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "swc src -d dist --config-file config.swcrc",
"start": "npm run build && node dist/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@swc/cli": "^0.1.63",
"@swc/core": "^1.3.102"
},
"dependencies": {
"@prisma/client": "^5.8.1",
"@sapphire/decorators": "^6.0.3",
"@sapphire/framework": "^5.0.6",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-subcommands": "^6.0.2",
"@sapphire/time-utilities": "^1.7.11",
"canvas": "^2.11.2",
"common-tags": "^1.8.2",
"discord.js": "^14.14.1",
"dot-prop": "^6.0.1",
"dotenv": "^16.3.1",
"ms": "^2.1.3",
"node-cron": "^3.0.3",
"prisma": "^5.8.1",
"ws": "^8.16.0"
}
}
I tried reinstalling my node modules.
Solution:
Try setting your module (and moduleResolution) to node16. They are the modern options for module stuff. Alternatively you can install and extend @sapphire/ts-config which will cover most of the config. - All of those subselections of esnext like esnext.array are implied by esnext so you're duplicating there - exclude isn't necessary like that. Exclude is to exclude something that was previously included, unless you have a node_modules directory inside src it does nothing - You can change include to just src, tsc will automatically resolve the whole directory glob....
Jump to solution
4 Replies
Favna
Favna5mo ago
Make sure you have import '@sapphire/plugin-api/register somewhere in your code. If you already do then please share your tsconfig.
b1nzee
b1nzee5mo ago
It's imported in my index.ts Here is my tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "ESNext",
"outDir": "dist",
"lib": [
"esnext",
"esnext.array",
"esnext.asynciterable",
"esnext.intl",
"esnext.symbol",
"dom"
],
"sourceMap": true,
"inlineSources": true,
"incremental": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"module": "commonjs",
"target": "ESNext",
"outDir": "dist",
"lib": [
"esnext",
"esnext.array",
"esnext.asynciterable",
"esnext.intl",
"esnext.symbol",
"dom"
],
"sourceMap": true,
"inlineSources": true,
"incremental": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
Solution
Favna
Favna5mo ago
Try setting your module (and moduleResolution) to node16. They are the modern options for module stuff. Alternatively you can install and extend @sapphire/ts-config which will cover most of the config. - All of those subselections of esnext like esnext.array are implied by esnext so you're duplicating there - exclude isn't necessary like that. Exclude is to exclude something that was previously included, unless you have a node_modules directory inside src it does nothing - You can change include to just src, tsc will automatically resolve the whole directory glob. - It is recommended to not enable skipLibCheck when possible - You should enable strict checking ("strict": true) to get full and proper tsc checking
b1nzee
b1nzee5mo ago
it works now, thank you