Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript syntax errors in node_modules/discord.js/typings/index.d.ts (Discord.JS)

I've been getting these typescript syntax errors, when I pulled from my git repo, updated all npm modules on my server and ran my start script. They are all typescript syntax errors.

I run my server by using npm run dev (which is a custom npm script i have in my package.json file), but the error persists even while using only npx tsc.

What I have tried:

  • reinstalling all node modules
  • updating all node modules
  • switching devices
  • setting skipLibCheck to true
  • setting checkJs to false
  • setting allowJs to false

It's almost as if typescript is ignoring the exclude parameter in tsconfig.json

Output from npx tsc:

$ npx tsc
node_modules/discord.js/typings/index.d.ts(1181,21): error TS1139: Type parameter declaration expected.
node_modules/discord.js/typings/index.d.ts(1181,27): error TS1434: Unexpected keyword or identifier.
node_modules/discord.js/typings/index.d.ts(1181,29): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
node_modules/discord.js/typings/index.d.ts(1182,9): error TS1005: ')' expected.
node_modules/discord.js/typings/index.d.ts(1182,11): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
node_modules/discord.js/typings/index.d.ts(1183,13): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1184,18): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1184,29): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1184,31): error TS1011: An element access expression should take an argument.
node_modules/discord.js/typings/index.d.ts(1185,3): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1185,4): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1196,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1196,21): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1196,29): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1197,9): error TS1005: ')' expected.
node_modules/discord.js/typings/index.d.ts(1198,13): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1198,14): error TS1134: Variable declaration expected.
node_modules/discord.js/typings/index.d.ts(1199,17): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1199,18): error TS1134: Variable declaration expected.
node_modules/discord.js/typings/index.d.ts(1199,29): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1199,30): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1200,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1200,4): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1211,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1211,24): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1211,42): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1211,49): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1212,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1212,24): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1212,43): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1212,53): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1213,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1213,25): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1213,43): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1213,50): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1214,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1214,25): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1214,44): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1214,54): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1215,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1215,24): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1215,42): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1215,49): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1216,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1216,24): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1216,43): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1216,53): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1217,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1217,22): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1217,40): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1217,47): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1218,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1218,22): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1218,41): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1218,51): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1219,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1219,24): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1219,33): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1220,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1220,22): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1220,40): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1220,47): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1221,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1221,22): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1221,41): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1221,51): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1222,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1222,28): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1222,46): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1222,53): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1223,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1224,9): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1225,14): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1226,4): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1227,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1228,9): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1229,13): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1230,4): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1231,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1232,9): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1233,14): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1234,4): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1235,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1235,25): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1235,43): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1235,50): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1236,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1236,25): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1236,44): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1236,54): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1237,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1237,28): error TS1005: ',' expected.
node_modules/discord.js/typings/index.d.ts(1237,35): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1238,3): error TS1128: Declaration or statement expected.
node_modules/discord.js/typings/index.d.ts(1238,29): error TS1109: Expression expected.
node_modules/discord.js/typings/index.d.ts(1238,39): error TS1005: ';' expected.
node_modules/discord.js/typings/index.d.ts(1239,1): error TS1128: Declaration or statement expected.

package.json

{
  "name": "parottu",
  "version": "3.23.41-alpha",
  "private": true,
  "main": "out/src/server.js",
  "dependencies": {
    "@prisma/client": "^4.12.0",
    "@types/jest": "^26.0.20",
    "axios": "^1.2.1",
    "bcryptjs": "^2.4.3",
    "better-logging": "^5.0.0",
    "body-parser": "^1.20.0",
    "chalk": "^4.1.2",
    "child_process": "^1.0.2",
    "cors": "^2.8.5",
    "discord.js": "^14.13.0",
    "dotenv": "^16.0.2",
    "express": "^4.18.1",
    "express-rate-limit": "^6.7.0",
    "glob": "^8.0.3",
    "method-override": "^3.0.0",
    "minimist": "^1.2.7",
    "morgan": "^1.10.0",
    "natural": "^6.3.0",
    "prisma": "^4.13.0",
    "prisma-field-encryption": "^1.4.1",
    "rotating-file-stream": "^3.0.4",
    "typescript": "^4.1.3",
    "web-vitals": "^0.2.4",
    "workbox-background-sync": "^5.1.4",
    "workbox-broadcast-update": "^5.1.4",
    "workbox-cacheable-response": "^5.1.4",
    "workbox-core": "^5.1.4",
    "workbox-expiration": "^5.1.4",
    "workbox-google-analytics": "^5.1.4",
    "workbox-navigation-preload": "^5.1.4",
    "workbox-precaching": "^5.1.4",
    "workbox-range-requests": "^5.1.4",
    "workbox-routing": "^5.1.4",
    "workbox-strategies": "^5.1.4",
    "workbox-streams": "^5.1.4"
  },
  "scripts": {
    "dev": "concurrently --kill-others \"cd ../Parottu-Client/ && npx react-scripts start\" \"dotenv -v USE_DEV_SERVER=true -- nodemon --watch src -e 'ts tsx js jsx html json' --exec 'npx tsc && node --inspect out/src/server.js'\""
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@tsconfig/node16": "^1.0.3",
    "@types/bcryptjs": "^2.4.2",
    "@types/body-parser": "^1.19.2",
    "@types/cors": "^2.8.13",
    "@types/express": "^4.17.17",
    "@types/glob": "^8.0.1",
    "@types/method-override": "^0.0.32",
    "@types/morgan": "^1.9.4",
    "@types/node": "^18.11.19",
    "concurrently": "^7.6.0",
    "dotenv-cli": "^6.0.0",
    "nodemon": "^2.0.20"
  },
  "description": "Share stories, talk & connect!"
}

tsconfig.json

{
    "compilerOptions": {
        "allowJs": false,
        "checkJs": false,
        "outDir": "out",
        "resolveJsonModule": true,
        "strict": false,
        "pretty": false,
    },
    "exclude": [ "node_modules" ],
    "include": [ "src/**/*" ]
}
like image 427
neksodebe Avatar asked Mar 03 '26 22:03

neksodebe


1 Answers

You have a mismatch between the typescript versions in your global and local npm workspace.

You can check it by running:

npm ls -g typescript
npm ls typescript

So to fix this, you can update the typescript in your local to the version in your global workspace:

npm install -D [email protected]
like image 166
Robin Thomas Avatar answered Mar 06 '26 12:03

Robin Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!