2

After installing express-jwt-blacklist, when I import it, it says it can't find the declaration file for the module.

My package.json dependencies:

{
  "name": "es6express",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "cross-env NODE_ENV=production && npm run server:prod",
    "server:prod": "node dist/app.js",
    "build": "babel app.js --out-dir build",
    "clean": "rimraf dist",
    "server": "cross-env DEBUG=app nodemon --exec babel-node app.js",
    "dev": "cross-env NODE_ENV=development npm-run-all server",
    "prod": "npm-run-all clean build",
    "format": "prettier --write \"./**/*.js\""
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^4.0.1",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "cross-env": "^7.0.2",
    "debug": "^4.1.1",
    "express": "^4.17.1",
    "express-jwt": "^6.0.0",
    "express-jwt-blacklist": "^1.1.0",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^5.9.6",
    "morgan": "^1.10.0",
    "rand-token": "^1.0.1",
    "lint": "eslint modules/**/*.js"
  },
  "devDependencies": {
    "@babel/cli": "^7.10.5",
    "@babel/core": "^7.9.0",
    "@babel/node": "^7.10.5",
    "@babel/preset-env": "^7.9.0",
    "babel-loader": "^8.1.0",
    "eslint": "^7.11.0",
    "nodemon": "^2.0.2",
    "npm-run-all": "^4.1.5",
    "prettier": "^1.19.1",
    "rimraf": "^3.0.2"
  }
}
Daniel_Knights
  • 7,940
  • 4
  • 21
  • 49
Kanti vekariya
  • 667
  • 3
  • 13
  • does your _node_modules_ folder contain the _express-jwt-blacklist_ package? Can you include your import statement? – H-H Oct 22 '20 at 10:50
  • yes, also import it like `import blacklist from 'express-jwt-blacklist'` – Kanti vekariya Oct 22 '20 at 10:54
  • 1
    This is the ES6 import format. For Node try the ES5 format : `const blacklist = require('express-jwt-blacklist');` – H-H Oct 22 '20 at 11:00
  • Yes, I know but I am using es6 syntax also i tried es5 syntax but still doesn't work. – Kanti vekariya Oct 22 '20 at 11:13
  • with such few info, it's hard to understand the problem. can you post the complete error message, a code snippet, or try to reinstall all modules with `npm install` – H-H Oct 22 '20 at 11:20
  • it's not throwing any error but display `Could not find a declaration file for module 'express-jwt-blacklist'. '/home/workspace/react-form/server/node_modules/express-jwt-blacklist/lib/index.js' implicitly has an 'any' type. Try npm install @types/express-jwt-blacklist if it exists or add a new declaration (.d.ts) file containing declare module express-jwt-blacklist ts(7016)` – Kanti vekariya Oct 22 '20 at 11:30
  • It seems to be a typescript error (which is not my area). are you using typescript? if that's the case express-jwt-blacklist may be missing a type file. you can check a similar question : https://stackoverflow.com/questions/41462729/typescript-react-could-not-find-a-declaration-file-for-module-react-material or https://stackoverflow.com/questions/50555859/typescript-could-not-find-a-declaration-file-for-module-react-cards – H-H Oct 22 '20 at 11:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/223453/discussion-between-kanti-vekariya-and-h-h). – Kanti vekariya Oct 22 '20 at 12:00

0 Answers0