【问题标题】:Error when install express-generator using npm使用 npm 安装 express-generator 时出错
【发布时间】:2020-11-01 17:05:36
【问题描述】:

我尝试使用命令 npm install express-generator 安装 express-generator,但出现以下错误。我在网上搜索,找不到任何有用的答案。

npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm ERR! Unexpected end of JSON input while parsing near '...DHZShvBYWKIIktsiBUuRD'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ASUS\AppData\Roaming\npm-cache\_logs\2020-07-12T10_29_10_754Z-debug.log

【问题讨论】:

    标签: node.js express npm npm-install express-generator


    【解决方案1】:

    WARN 与消息的其余部分无关。只是,一个 WARN,它应该给使用过时的 deps 的 package mantainers,而不是你。

    ERR(s) 表示 npm 无法在某处解析 JSON 内容,除此之外别无其他。

    在深入研究它向您显示的日志文件之前,请尝试清理您的缓存以涵盖缓存条目损坏或不一致以及 npm 崩溃的常见情况,因为它试图提高效率。

    鉴于您使用的是windows,以管理员身份打开控制台(CMD和Powershell都应该可以,但我没有windows机器atm)并运行

    npm cache clean --force
    

    或者,运行

    npm doctor
    

    除其他检查外,将验证缓存的包并查明损坏或不一致的包。

    使用更新你的 npm 版本到最新版本也没有什么坏处

    npm install -g npm
    

    完成后,再次尝试运行 express-generator。

    【讨论】:

      猜你喜欢
      • 2016-01-03
      • 2020-09-23
      • 2016-01-31
      • 1970-01-01
      • 1970-01-01
      • 2014-12-16
      • 2017-06-17
      • 1970-01-01
      • 2016-03-04
      相关资源
      最近更新 更多