1

I followed Link to install the npm package from the file path

However, when I try to use it I am getting the following error.

Cannot file moduele '<module_name>' or its corresponding type declaration

Is there any tutorial to follow in order to install typescript-based npm package locally?

Here my package.json of the package i want to install

    {
  "name": "sqs",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.ts",
  "types": "dist/index.d.ts",
  "scripts": {
    "build": "rm -rf build && prettier --write src/ && tsc",
    "start": "ts-node ./src/index.ts",
    "start:prod": "npm run build && node ./dist/src/index.js",
    "start:dev": "./node_modules/nodemon/bin/nodemon.js",
    "lint": "eslint '*/**/*.{js,ts,tsx}'",
    "lint:fix": "eslint --fix '*/**/*.{js,ts,tsx}'",
    "prettier": "prettier -c ./src/**/*.{js,ts,tsx,scss,css,md}",
    "prettier:fix": "prettier -c ./src/**/*.{js,ts,tsx,scss,css,md} --write"
  },
  "author": "Rohit Sthapit",
  "license": "ISC",
  "dependencies": {
    "aws-sdk": "^2.820.0",
    "nodemon": "^2.0.20",
    "readline-sync": "^1.4.10",
    "ts-node": "^10.9.1"
  },
  "devDependencies": {
    "@types/dotenv": "^8.2.0",
    "@typescript-eslint/eslint-plugin": "^5.36.2",
    "@typescript-eslint/parser": "^5.36.2",
    "dotenv": "^8.2.0",
    "eslint": "^8.23.1",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-prettier": "^4.2.1",
    "prettier": "^2.7.1"
  }
}
Rohit Sthapit
  • 454
  • 4
  • 14

2 Answers2

1

Usually for packages that support typescript, you would find a DT symbol when you open the package page in npm.
enter image description here

For installing the typescript package, you use npm i @types/{package_name}. For eg, in lodash's case you could do:

npm i @types/lodash

Hope it helps!!

Krushnal Patel
  • 422
  • 2
  • 14
0

use this, npm install --save-dev @types/package-name

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 27 '23 at 19:18