【问题标题】:"ng new app-name" results in "npm ERR! Maximum call stack size exceeded"“ng new app-name”导致“npm ERR!超出最大调用堆栈大小”
【发布时间】:2019-03-01 12:51:27
【问题描述】:

在 Mac 上,我正在尝试按照 Angular.io 教程 (https://angular.io/tutorial/toh-pt0) 中的步骤进行操作

$node -v
v8.11.4

$npm -version
6.4.1

$npm install -g @angular/cli
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
+ @angular/cli@6.2.3
updated 1 package in 6.533s

$ng new angular-tour-of-heroes
CREATE angular-tour-of-heroes/e2e/src/app.e2e-spec.ts (318 bytes)
CREATE angular-tour-of-heroes/e2e/src/app.po.ts (208 bytes)
npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/XXXXXX/.npm/_logs/2018-09-25T19_56_34_147Z-debug.log
Package install failed, see above.

我已经尝试过几次了。为什么我在运行ng new angular-tour-of-heroes 时不断收到错误消息npm ERR! Maximum call stack size exceeded

【问题讨论】:

  • 清理 npm 缓存并尝试命令 - npm cache clean --force
  • 感谢@HrishikeshKale,但这没有帮助。运行命令后,同样的错误仍然存​​在。
  • 你能按照这个步骤确认 npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest
  • 不走运@HrishikeshKale:我试过 1) npm uninstall -g @angular/cli 2) npm cache clean --force 3) npm install -g @angular/cli@latest 4) ng new angular -tour-of-heroes --force -> 与上面显示的结果完全相同

标签: angular-cli angular6


【解决方案1】:

终于找到了上述问题的答案->https://github.com/facebook/create-react-app/issues/5328#issuecomment-429148117

罪魁祸首是位于用户主目录 Users/you/.npmrc 中的 .npmrc 文件。删除文件后,一切都很好。

【讨论】:

【解决方案2】:

我也面临同样的问题。但经过很长时间我发现这是因为版本问题。我将 node、npm 和 angular/cli 更新到最新版本,然后这个问题得到解决。 要更新 npm,请使用此命令

npm install -g npm@latest

要更新 angular/cli,请使用此命令

npm uninstall -g angular-cli
npm cache clean (or)  npm cache verify (if npm > 5)
npm install @angular/cli@latest

之后它工作正常。谢谢。

【讨论】:

    【解决方案3】:

    在 Windows 10 上遇到同样的问题,使用 node-v11.14.0-win-x64 zip 安装。

    在此页面上尝试了两个答案:

    1. ~/.npmrc 文件被删除——该位置不存在
    2. 更新 npm(6.7.0 到 6.9.0)并重新安装 angular/cli(从 7.3.8 到 7.3.9)

    运气不好。
    对我有用的是:

    1. $ npm cache clean --force
    2. 安装 LTS 版本:node-v10.15.3-win-x86(再次压缩安装)。 (更新 .bashrc 中的路径以指向 LTS 节点发行版)
    3. 在我的开发源代码树下发现了一个 node_modules 和 package-lock.json -- 也删除了这些。

    (无需再次安装 angular/cli 和 typescript,只需将这些目录从 11.14 的 node_modules 复制到 10.15 下的目录即可。
    同样适用于 ng、tsc、tsserver 和 .cmd 文件)

    然后 ng new app-name 起作用了。 所以在选择节点 LTS 版本和清理缓存之间有些工作。

    如果这不起作用,我会尝试installing YARN

    【讨论】:

      【解决方案4】:

      它对我有用,请在下面尝试 -

      .npmrc 要从C:\Users\you 中删除的文件

      【讨论】:

        猜你喜欢
        • 2020-08-03
        • 2021-02-12
        • 1970-01-01
        • 2023-01-26
        • 1970-01-01
        • 2019-07-19
        • 2014-11-17
        • 2019-09-09
        • 1970-01-01
        相关资源
        最近更新 更多