Angular-cli: npm ERR! Installing ERROR | Unexpected end of JSON input while parsing near '...'

Created on 21 Nov 2017  路  14Comments  路  Source: angular/angular-cli

C:UsersSandeep>npm install -g @angular/cli
npm ERR! Unexpected end of JSON input while parsing near '...a57e4c92ba141aa2c17fb'

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersSandeepAppDataRoamingnpm-cache_logs2017-11-21T16_00_37_726Z-debug.log

C:UsersSandeep>npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.

C:UsersSandeep>node -v
v8.9.1

C:UsersSandeep>npm -v
5.5.1

I am not sure why angular latest version is not installing on my machine.

Most helpful comment

Try clearing npm cache nd then try again. Should work fine
npm cache clean --force

All 14 comments

This seems like a problem with your node/npm and not with Angular CLI.

Please have a look at the fixing npm permissions page, common errors page, npm issue tracker, or open a new issue if the problem you are experiencing isn't known.

I m having with same issue.

I am getting the same issue how to resolve it.

I am getting a similar error when creating a new angular project.
Windows 10 home
angular-cli 1.6.0
npm 5.6.0
node 8.9.3

* running nodeJS CMD as administrator *

after globally installing angular-cli now trying to create a first project
see ouptut

C:Angular-Projects>ng new maxdocs --style=scss --routing --verbose
create maxdocs/e2e/app.e2e-spec.ts (289 bytes)
create maxdocs/e2e/app.po.ts (208 bytes)
create maxdocs/e2e/tsconfig.e2e.json (235 bytes)
create maxdocs/karma.conf.js (923 bytes)
create maxdocs/package.json (1312 bytes)
create maxdocs/protractor.conf.js (722 bytes)
create maxdocs/README.md (1023 bytes)
create maxdocs/tsconfig.json (363 bytes)
create maxdocs/tslint.json (3040 bytes)
create maxdocs/.angular-cli.json (1244 bytes)
create maxdocs/.editorconfig (245 bytes)
create maxdocs/.gitignore (516 bytes)
create maxdocs/src/assets/.gitkeep (0 bytes)
create maxdocs/src/environments/environment.prod.ts (51 bytes)
create maxdocs/src/environments/environment.ts (387 bytes)
create maxdocs/src/favicon.ico (5430 bytes)
create maxdocs/src/index.html (294 bytes)
create maxdocs/src/main.ts (370 bytes)
create maxdocs/src/polyfills.ts (2405 bytes)
create maxdocs/src/styles.scss (80 bytes)
create maxdocs/src/test.ts (1085 bytes)
create maxdocs/src/tsconfig.app.json (211 bytes)
create maxdocs/src/tsconfig.spec.json (304 bytes)
create maxdocs/src/typings.d.ts (104 bytes)
create maxdocs/src/app/app-routing.module.ts (245 bytes)
create maxdocs/src/app/app.module.ts (395 bytes)
create maxdocs/src/app/app.component.html (1173 bytes)
create maxdocs/src/app/app.component.spec.ts (1103 bytes)
create maxdocs/src/app/app.component.ts (208 bytes)
create maxdocs/src/app/app.component.scss (0 bytes)
Installing packages for tooling via npm.
npm ERR! Unexpected end of JSON input while parsing near '..."1.1.0","jasminewd2":'
npm ERR! A complete log of this run can be found in:
npm ERR! C:UserspickledhamAppDataRoamingnpm-cache_logs2017-12-10T19_35_37_928Z-debug.log
Package install failed, see above.

Try clearing npm cache nd then try again. Should work fine
npm cache clean --force

Clearing the npm cache doesnt solve this issue.
Cleaned the cacahe, removed package-lock.json even tried installing another version of Node with nvm still no luck.

On a new Angular project it works.

No logs, no clue where the error exists.

@filipesilva Any more clue where can this go wrong?

I resolved this problem on my local machine. I _had_ @angular/cli 1.7.3 defined in my package.json. I:

  1. Manually changed the @angular/cli version in my package.json to ^6.0.5
  2. Ran npm install
  3. Ran ng update @angular/cli without a problem.

@AryanJ-NYC are you sure npm install is working? we should npm install @angular/cli

my solution:

switch registry to https://registry.npmjs.org/
and use proxy in order to get better network.

and then try
npm cache clean --force
npm install --save-dev @angular/cli@latest

everything goes well.

@nevernet npm install _does_ install @angular/cli since I manually changed the @angular/cli version in package.json.

all above solutions are not working for me

Try this
npm cache clean --force

@webuilderkrish

cd <project root folder>
echo 'registry=https://registry.npmjs.org/'  > .npmrc

maybe you could use http proxy in order to get better network.

and then try

rm -rf node_modules dist
npm cache clean --force
npm install --save-dev @angular/cli@latest

everything goes well.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngvarKofoed picture IngvarKofoed  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

daBishMan picture daBishMan  路  3Comments

delasteve picture delasteve  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments