当创建一个新的Angular 5项目时:

节点版本号:8.9.2

NPM版本:5.5.1

我的命令是:

npm install -g @angular/cli

错误是:

npm ERR! **Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'**
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aashitec\AppData\Roaming\npm-cache\_logs\2017-12-06T13_10_10_729Z-debug.log

错误日志在这里


当前回答

在运行以下代码后,我得到了错误(文件已经存在——强制覆盖):

npm cache clean --force
npm install -g @angular/cli

我用:

npm i -g --force npm

确保运行第一个命令来刷新npm的缓存。

其他回答

删除C:\Users\admin\AppData\Roaming\ (windows)目录下的npm和npm-cache文件夹 然后执行CMD

NPM缓存清除——force NPM缓存验证

更新NPM到最新版本

npm啊,g pm

然后创建项目 1)角

npm i -g @angular/cli@latest 新的你好世界

2)反应

NPM I -g create-react-app create-react-app react-app

首先卸载现有的npm包: NPM卸载-g create-react-app(如果是全局安装) 其次: NPM缓存清理——force 第三: NPM install -g create-react-app@latest并重新创建-react-app my-app。

这为我解决了问题:

以管理员身份打开Windows Powershell

npm cache clean --force
npm install -g @angular/cli

https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/

这里的30个答案都不适合我。我需要:

删除node_modules和package-lock.json NPM缓存清理——force NPM install -g @angular/cli NPM I——仅包锁 npm ci

唷!

尝试设置

NPM配置strict-ssl为false

然后试着跑步,

NPM install -g @angular/cli