not able to install request type definition in typescript

407 Views Asked by At

I am new to typescript. As I was following a video tutorial of using a request api. I used following command to install request library:

npm install request --save

then, in order to use auto-complete in visual studio code editor for typescript, I tried installing type definition for request:

npm install @types/request --save-dev

But I got this below error while doing so:

npm ERR! Unexpected end of JSON input while parsing near '...57","dependencies":{}'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ABC\AppData\Roaming\npm-cache\_logs\2020-02-05T09_09_06_453Z-debug.log

I even followed this link : https://www.npmjs.com/package/@types/request

the video tutorial that I was following was : this

NOTE : I am facing this problem in my windows 7 laptop. When I tried the same steps in other laptop with windows 10, all commands run smoothly. No error.

kindly tell me what can I do next in order to continue doing practice and learning on this REQUEST topic.

package.json file

{
  "name": "typescriptbasics",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
   "start":"tsc && node ./out/index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "lodash": "^4.17.15",
    "request": "^2.88.0"
  },
  "devDependencies": {
    "@types/lodash": "^4.14.149"
  }
}

Full Error Log

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '@types/request',
1 verbose cli   '--save-dev'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session fb9add68865522cb
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/@types%2frequest 247ms (from cache)
8 silly pacote tag manifest for @types/request@latest fetched in 263ms
9 timing stage:loadCurrentTree Completed in 1271ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 133ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule @types/[email protected] checking installable status
17 http fetch GET 304 https://registry.npmjs.org/@types%2fcaseless 72ms (from cache)
18 silly pacote range manifest for @types/caseless@* fetched in 73ms
19 silly resolveWithNewModule @types/[email protected] checking installable status
20 http fetch GET 304 https://registry.npmjs.org/@types%2fnode 134ms (from cache)
21 silly fetchPackageMetaData error for @types/node@* Unexpected end of JSON input while parsing near '...57","dependencies":{}'
22 http fetch GET 304 https://registry.npmjs.org/@types%2ftough-cookie 143ms (from cache)
23 silly pacote range manifest for @types/tough-cookie@* fetched in 146ms
24 silly resolveWithNewModule @types/[email protected] checking installable status
25 http fetch GET 304 https://registry.npmjs.org/form-data 151ms (from cache)
26 silly pacote range manifest for form-data@^2.5.0 fetched in 153ms
27 silly resolveWithNewModule [email protected] checking installable status
28 timing stage:rollbackFailedOptional Completed in 1ms
29 timing stage:runTopLevelLifecycles Completed in 1570ms
30 silly saveTree [email protected]
30 silly saveTree +-- @types/[email protected]
30 silly saveTree +-- @types/[email protected]
30 silly saveTree | +-- @types/[email protected]
30 silly saveTree | +-- @types/[email protected]
30 silly saveTree | `-- [email protected]
30 silly saveTree |   +-- [email protected]
30 silly saveTree |   +-- [email protected]
30 silly saveTree |   | `-- [email protected]
30 silly saveTree |   `-- [email protected]
30 silly saveTree |     `-- [email protected]
30 silly saveTree +-- [email protected]
30 silly saveTree `-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   | +-- [email protected]
30 silly saveTree   | | +-- [email protected]
30 silly saveTree   | | +-- [email protected]
30 silly saveTree   | | +-- [email protected]
30 silly saveTree   | | `-- [email protected]
30 silly saveTree   | |   `-- [email protected]
30 silly saveTree   | `-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   | +-- [email protected]
30 silly saveTree   | +-- [email protected]
30 silly saveTree   | | +-- [email protected]
30 silly saveTree   | | +-- [email protected]
30 silly saveTree   | | `-- [email protected]
30 silly saveTree   | |   `-- [email protected]
30 silly saveTree   | `-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   | `-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   | `-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   | `-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   +-- [email protected]
30 silly saveTree   |   `-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   | +-- [email protected]
30 silly saveTree   | `-- [email protected]
30 silly saveTree   +-- [email protected]
30 silly saveTree   `-- [email protected]
31 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...57","dependencies":{}'
31 verbose stack     at JSON.parse (<anonymous>)
31 verbose stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
31 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
31 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
32 verbose cwd C:\Users\Wpits\Downloads\Chili\TypeScriptBasics
33 verbose Windows_NT 6.1.7601
34 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@types/request" "--save-dev"
35 verbose node v12.13.1
36 verbose npm  v6.12.1
37 error Unexpected end of JSON input while parsing near '...57","dependencies":{}'
38 verbose exit [ 1, true ]
0

There are 0 best solutions below