0

I get the the above error when I ran the command npm install -g @angular/cli the complete logs are as below

verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ain" : "src/index.js"'
78 verbose stack at JSON.parse (<anonymous>)
78 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
78 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
78 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
79 verbose cwd C:\Users\E079233\Coinnov\CoInnovUI
80 verbose Windows_NT 10.0.17763
81 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
82 verbose node v12.18.2
83 verbose npm v6.14.5
84 error Unexpected end of JSON input while parsing near '...ain" : "src/index.js"'
85 verbose exit [ 1, true ]

I tried npm cache clean --force and npm install @angular/cli@latest as suggested in another answer but it didn't work

Please suggest a possible way to fix this issue.

2 Answers 2

2

If you stumble upon this thread searching for answers and nothing suggested in other threads has helped you, then maybe the problem is in your private npm registry. As for me it was very slow responding and, as I think, connection closed eventually by timeout causing JSON with package metadata being invalid AND also storing such invalid JSON in npm cache.
The fix for me was to explicitly set registry for packages from our scope:

npm config set @myco:registry http://reg.example.com

This ensures that ONLY your company scope packages are downloaded from set registry, and others are from global registry. Also make sure you don't overwrite this setting by local .npmrc file in your repo root.

Sign up to request clarification or add additional context in comments.

Comments

0

It seems you are seeing issues because of npm.

Please try out ::

npm cache clean --force

npm i -g npm

npm i -g @angular/cli@latest

npm i or npm install both are same. Please dont get confused

2 Comments

I tried this out already. And get the same error as mentioned above when I try to run npm i -g @angular/cli@latest
Please tell the version of node you are using

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.