1

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:

enter image description here

What can I do to solve this error?

2

3 Answers 3

6

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 
Sign up to request clarification or add additional context in comments.

1 Comment

Welcome to SO. Please edit your post so that it (a) relates to the question ("this" and "that" is a bit misleading) and (b) that you explain why/ how your suggestion solves the issue.
0

you should probably update your angular cli version:

npm install -g @angular/cli
ng new my-app

Comments

0

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:

  1. Clean npm cache: npm cache clean --force
  2. Verify the contents of the cache folder: npm cache verify

This 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.

Comments

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.