【发布时间】: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 serve或ng serve --open=true? -
大声笑,我实际上只是尝试使用
ng serve,它没有问题.. 为什么会这样,为什么角度初学者指南建议使用 cmdng serve --open.. 真的很好奇现在到这个 :) ? -
只是阅读它,它完全有意义..因为我正在通过 ssh 隧道连接到运行应用程序的服务器.. 所以 --open 使用没有意义:)
-
不知道为什么初学者指南上会这样写,但我一直使用
ng serve,它对我来说很好用。
标签: node.js angular npm angular-cli ubuntu-18.04