【问题标题】:npm ERR! Unexpected end of JSON input while parsingnpm 错误!解析时 JSON 输入意外结束
【发布时间】:2021-10-24 00:34:13
【问题描述】:

在 Angular 项目中执行 ng new project-name 时出现以下错误

npm WARN 不推荐使用 circular-json@0.5.9: CircularJSON 仅在维护中,flatted 是它的继任者。
npm 错误!在 '...:"~0.0.0","webpack-de' 附近解析时 JSON 输入意外结束

npm 错误!可以在以下位置找到此运行的完整日志:
npm 错误! C:\Users\Abhi\AppData\Roaming\npm-cache_logs\2018-12-13T10_24_02_151Z-debug.log
包安装失败,见上。

我尝试过的:
1. npm 缓存清理 --force
2. npm 缓存验证
3. npm 错误!在 '...5.0","rimraf":"^2.2.8' 附近解析时 JSON 输入意外结束

当前版本:
节点:10.14.2
NPM : 6.5.0
操作系统:Windows

【问题讨论】:

  • npm uninstall -g angular-cli npm cache clean 之后尝试这个npm install -g angular-cli 在那个尝试之后
  • @Abhishek 在安装 angular-cli 时遇到同样的错误
  • 发布您的package.json 文件
  • @PatrickHollweck 我是 Angular 的新手。你能告诉我在哪里可以找到那个文件吗?

标签: angular npm angular-cli


【解决方案1】:

您无需卸载或安装任何东西。只是

npm cache clean --force

然后

npm install

会的。

【讨论】:

  • 与其他现有答案有什么区别?
  • 您不需要卸载或安装任何东西,只需npm cache clean --force 然后npm install 就可以了
【解决方案2】:

在您尝试创建项目设置的文件夹中,只需运行以下 2 个命令:

  1. npm cache clean --force
  2. npm install

然后,运行设置项目目录所需的命令。

【讨论】:

    【解决方案3】:

    此问题已通过转到 C:\Users\USERNAME\AppData\Roaming\npm-cache 并手动删除其内容,然后以管理员身份运行 cmd 并运行 npm install 解决了p>

    【讨论】:

      【解决方案4】:

      adminstator模式打开cmd然后依次运行以下命令指定

      npm cache clean --force 
      go in the c:/user/user_name/AppData/Roaming/npm     => clean this folder 
      npm install -g @angular/cli
      ng new project_name
      

      希望它会起作用。

      【讨论】:

        【解决方案5】:
        delete node_modules folder
        delete package-lock.json 
        npm clear cache -f
        npm i
        

        【讨论】:

          猜你喜欢
          • 2021-01-04
          • 1970-01-01
          • 1970-01-01
          • 2020-09-18
          • 2019-10-16
          • 1970-01-01
          • 1970-01-01
          • 2020-09-11
          • 1970-01-01
          相关资源
          最近更新 更多