npm ERR! Unexpected end of JSON input while parsing near

▼魔方 西西 提交于 2020-06-24 14:42:26

问题


when creating a new angular project after running npm install -g @angular/cli I am getting the following error

npm ERR! Unexpected end of JSON input while parsing near '...:"^2.1.0","ntypescrip'

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\Suraj\AppData\Roaming\npm-cache_logs\2019-06-28T06_04_16_049Z-debug.log Package install failed, see above.


回答1:


Try:-

As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. If you're sure you want to delete the entire cache, rerun this command with --force.

step 1)

$ npm cache clean --force

or

$ npm cache verify

step 2)

$ npm install -g @angular/cli@latest

or

try uninstalling and installing angular/cli

step 3)

$ npm install --save-dev @angular/cli@latest

step 4)

delete node_modules and run $ npm install




回答2:


Delete npm and npm cache in C:\Users\beni\AppData\Roaming and then re-create your app and then it works fine .




回答3:


This solved it for me:

Open Windows Powershell as admin

npm cache clean --force

npm install -g @angular/cli



回答4:


Just follow these steps :

step 1 - install angular CLI
npm install @angular/cli

step 2 - create a new project
ng new NAME_PROJECT and press enter the let the default values

step 3 - open the folder "NAME_PROJECT" and run this cmd :
ng serve



来源:https://stackoverflow.com/questions/56801803/npm-err-unexpected-end-of-json-input-while-parsing-near

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!