1

I am new to Angular. I am facing problem in creation of project whenever I try to create project using ng new Angular, it ends with an error :

npm ERR! Unexpected end of JSON input while parsing near '...ries":{},"dist":{"int'

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Vaibhav\AppData\Roaming\npm-cache_logs\2018-10-21T14_00_17_881Z-debug.log Package install failed, see above.

I am following this tutorial. I am on windows 10 64-bit.

First I downloaded Node.js from this URL.

Then I checked version using npm -v

Then installed angular using npm install -g @angular/cli.

Then I changed my directory to where I want my Angular project using cd command.

After that I entered ng new Angular this command.

And at last it ended with this :

? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
CREATE Angular/angular.json (3777 bytes)
CREATE Angular/package.json (1314 bytes)
CREATE Angular/README.md (1024 bytes)
CREATE Angular/tsconfig.json (408 bytes)
CREATE Angular/tslint.json (2837 bytes)
CREATE Angular/.editorconfig (245 bytes)
CREATE Angular/.gitignore (503 bytes)
CREATE Angular/src/favicon.ico (5430 bytes)
CREATE Angular/src/index.html (294 bytes)
CREATE Angular/src/main.ts (372 bytes)
CREATE Angular/src/polyfills.ts (3234 bytes)
CREATE Angular/src/test.ts (642 bytes)
CREATE Angular/src/styles.css (80 bytes)
CREATE Angular/src/browserslist (388 bytes)
CREATE Angular/src/karma.conf.js (964 bytes)
CREATE Angular/src/tsconfig.app.json (166 bytes)
CREATE Angular/src/tsconfig.spec.json (256 bytes)
CREATE Angular/src/tslint.json (314 bytes)
CREATE Angular/src/assets/.gitkeep (0 bytes)
CREATE Angular/src/environments/environment.prod.ts (51 bytes)
CREATE Angular/src/environments/environment.ts (662 bytes)
CREATE Angular/src/app/app.module.ts (314 bytes)
CREATE Angular/src/app/app.component.html (1141 bytes)
CREATE Angular/src/app/app.component.spec.ts (981 bytes)
CREATE Angular/src/app/app.component.ts (211 bytes)
CREATE Angular/src/app/app.component.css (0 bytes)
CREATE Angular/e2e/protractor.conf.js (752 bytes)
CREATE Angular/e2e/tsconfig.e2e.json (213 bytes)
CREATE Angular/e2e/src/app.e2e-spec.ts (303 bytes)
CREATE Angular/e2e/src/app.po.ts (208 bytes)
npm ERR! Unexpected end of JSON input while parsing near '...ries":{},"dist":{"int'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Vaibhav\AppData\Roaming\npm-cache\_logs\2018-10-21T14_00_17_881Z-debug.log
Package install failed, see above.

I tried: 1. Reinstalling node.js. 2. Running cmd as administrator.

What should I do now? Any help is appreciated. Thank You.

Regards,
Vaibhav M

Vaibhav Mandlik
  • 51
  • 2
  • 13
  • This might be resolved with the answer accepted in [this question](https://stackoverflow.com/questions/47675478/npm-install-errorunexpected-end-of-json-input-while-parsing-near-nt-webpack). – flags Mar 02 '20 at 15:38

2 Answers2

1

In my case, I solved it by observing l'll things other than Angular.

First: My antivirus was blocking it, so I uninstalled it. (I don't know why and how, but uninstalling my anti virus released me from some problem).

Second: Reinstalled node.js.

Third: I tried command given in this answer (The rm -rf node_modules/ command didn't worked for me so I skipped it).

And it worked like a charm for me. I posted it because may be it'll help someone.

Thank You.

Vaibhav Mandlik
  • 51
  • 2
  • 13
0

In my case the error is caused by the firebase-admin package... still trying to figure out how to fix that though. I just have a few dependencies and I am npm-installing each of them individually.

gianni
  • 1,199
  • 2
  • 14
  • 28