Невозможно открыть localhost из-за UnhandledPromiseRejectionWarning: Ошибка: выход с кодом 3 - PullRequest
0 голосов
/ 14 марта 2019

Пробовал переустанавливать node_modules для "my-app", но проблема сохраняется с opn / index.js Ошибка: выход с кодом 3. Теперь xdg-open имеет разрешения на выполнение

[root@localhost my-app]# ng serve --open
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2019-03-14T13:15:55.316Z
Hash: bde8066a5f0c0f28e4f3
Time: 7824ms
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 284 kB [initial] [rendered]
chunk {main} main.js, main.js.map (main) 11.5 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 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.76 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.
(node:49888) UnhandledPromiseRejectionWarning: Error: Exited with code 3
    at ChildProcess.cp.once.code (/var/www/html/my-app/node_modules/opn/index.js:84:13)
    at Object.onceWrapper (events.js:277:13)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:597:12)
(node:49888) 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:49888) [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.
^C
[root@localhost my-app]#

Заранее спасибо за помощь

1 Ответ

0 голосов
/ 07 мая 2019

сначала проверьте вашу функцию уловки или ошибки.

это один пример

new Promise((_, reject) => reject(new Error('woops'))).
  catch(error => { console.log('caught', err.message); });

Это выдаст эту ошибку

$ node test.js
(node:9825) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ReferenceError: err is not defined
(node:9825) 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.

Именно поэтому необработанные отклонения могутбыть таким коварнымВы можете подумать, что обнаружили ошибку, но ваш обработчик ошибок мог вызвать другую ошибку.Подобная проблема возникает, если вы возвращаете обещание в функции .catch().

Я предлагаю вам посмотреть эту ссылку

...