Angular CLI UnhandledPromiseRejection关于全新安装的警告

时间:2018-12-06 21:05:10

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

我目前正在尝试通过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.

我不知道为什么会这样,因为我使用的是全新安装,而没有碰到cli创建的代码。

当前正在运行ubuntu 18.04,节点v11.3.0,npm v6.4.1和angular-cli 7.1.1(如上所述)

我也曾尝试删除并安装node_modules文件夹,但是没有运气。看起来像是导致问题的OPN文件,但我不确定为什么。

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

1 个答案:

答案 0 :(得分:2)

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

显然,此警告未在上一版本的angular-cli 6.1.5中显示。我正在从事的项目正在运行。

再次感谢GCSDC! :)

相关问题