【问题标题】:Angular CLI UnhandledPromiseRejectionWarning on fresh installAngular CLI UnhandledPromiseRejectionWarning 全新安装
【发布时间】:2018-12-07 05:49:19
【问题描述】:

我目前正在尝试通过ng new ProjectName 启动一个新的 Angular CLI (v7.1.1) 项目,它似乎可以正常工作。然后当我运行ng serve --open 命令时,它似乎成功结束,但输出以下警告/错误:

$ ng serve --open
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-12-06T20:40:39.900Z
Hash: b89537a5317a31d5ae15
Time: 4712ms
chunk {main} main.js, main.js.map (main) 11.5 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 223 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.3 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.67 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.
(node:3844) UnhandledPromiseRejectionWarning: Error: Exited with code 3
    at ChildProcess.cp.once.code (/~path/to/project/node_modules/opn/index.js:84:13)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:978:16)
    at Socket.stream.socket.on (internal/child_process.js:395:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:616:12)
(node:3844) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3844) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我不知道为什么会发生这种情况,因为我使用的是全新安装而没有触及 Angular cli 创建的代码。

当前运行 ubuntu 18.04、node v11.3.0、npm v6.4.1 和 angular-cli 7.1.1(如前所述)

我也尝试删除和安装 node_modules 文件夹,但没有成功。它看起来像是导致问题的 OPN 文件,但我不知道为什么。

还有其他人遇到这个问题吗?

【问题讨论】:

  • 您是否尝试只运行ng serveng serve --open=true
  • 大声笑,我实际上只是尝试使用ng serve,它没有问题.. 为什么会这样,为什么角度初学者指南建议使用 cmd ng serve --open.. 真的很好奇现在到这个 :) ?
  • 只是阅读它,它完全有意义..因为我正在通过 ssh 隧道连接到运行应用程序的服务器.. 所以 --open 使用没有意义:)
  • 不知道为什么初学者指南上会这样写,但我一直使用ng serve,它对我来说很好用。

标签: node.js angular npm angular-cli ubuntu-18.04


【解决方案1】:

根据 GCSDC 的评论,我发现了问题所在,或者至少发现了如何不出现错误/警告。这是因为我使用的是--open,它试图在网页上打开浏览器。但由于运行应用程序的服务器是我通过 ssh 连接到的服务器(并通过隧道连接端口),因此使用它没有意义--open 然后我们就没有错误/警告了。

显然这个警告没有出现在 angular-cli 6.1.5 中,前一个。我正在做的项目正在运行。

再次感谢 GCSDC! :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-26
    • 1970-01-01
    • 2017-02-14
    • 2018-06-29
    • 2019-07-25
    • 1970-01-01
    • 2019-07-14
    相关资源
    最近更新 更多