When I try to create a new project with Angular CLI, ng new project-name, I get the following error:
npm ERR! Unexpected end of JSON input while parsing near '...+EuGeFfIM3zMCaRLePh7u'
Screenshot of the error:
What can I do to solve this error?
When I try to create a new project with Angular CLI, ng new project-name, I get the following error:
npm ERR! Unexpected end of JSON input while parsing near '...+EuGeFfIM3zMCaRLePh7u'
Screenshot of the error:
What can I do to solve this error?
I don't know what you're trying to do, but this problem usually happens because of npm cache, so, first clean npm cache with following command and then try again.
npm cache clean --force
you should probably update your angular cli version:
npm install -g @angular/cli
ng new my-app
I had the same problem, and it was after a forced reboot due to a crash, at least I think so, I don't remember doing anything else unusual. However, somehow npm cache was corrupted.
To solve it I followed this guide, basically the solution is:
npm cache clean --forcenpm cache verifyThis second command doesn't make much sense to me after clearing the cache. Perhaps I am ignoring some facts about how the npm cache works.
If the error persists after that, in my case it did, then try updating npm: npm i npm@latest -g.
I never knew if only with npm cache verify and/or npm i npm@latest -g the error could be solved.