【问题标题】:npm ERR! Unexpected end of JSON input while parsing near '...npmjs.org/prelude-ls/'npm 错误!在“...npmjs.org/prelude-ls/”附近解析时 JSON 输入意外结束
【发布时间】:2022-05-06 17:27:09
【问题描述】:

尝试运行:

npm install @angular-devkit/build-angular

安装时进入下方

npm 错误!在“...npmjs.org/prelude-ls/”附近解析时 JSON 输入意外结束

请帮忙

【问题讨论】:

    标签: angular-cli


    【解决方案1】:

    清理损坏的本地 npm 缓存可能会修复此错误。

    npm cache clean --force
    

    只需在终端中执行上述命令后再次运行 npm 命令即可。


    如官方文档here 中所述,JSON 无效可能有其他几个原因。

    npm 官方网站已详细记录了大多数常见错误。但不幸的是,当您搜索错误时,它们并没有出现在顶部结果中。

    【讨论】:

      【解决方案2】:

      我也遇到了同样的问题。尝试使用以下命令。它对我有用。

      **npm cache clean --force**
      

      或者你可以尝试删除下面列出的所有文件问题会解决。

      > For Windows : go to C:\Users\username\AppData\Roaming\npm-cache 
      > Delete all files and install angular again.
      

      【讨论】:

        【解决方案3】:

        如果您使用 IntelliJ 并且在 Mac 上并通过 VPN 连接 - 运行 npm install 时,我不断收到“在附近解析时 JSON 输入意外结束”。

        我看过这里:- NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'

        我试过了

        1. 删除 package-lock.json
        2. sudo npm 缓存验证
        3. sudo npm cache clean --force
        4. sudo npm 更新
        5. sudo rm -rf node_modules
        6. sudo npm install --force
        7. 删除 repo 并从头开始

        我在 IntelliJ 嵌入式终端仿真器中尝试了所有这些命令。我在 Mac bash 终端上尝试了 npm install ,它工作正常。因此,即使两者都使用默认的 bash shell,IntelliJ 终端也会增加一些额外的开销,并且当通过办公室 VPN 连接时,它似乎会超时。

        【讨论】:

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