为我的第一个Angular应用程序运行“ngserve”时出错

消息&跟踪:

Generating browser application bundles (phase: building)...(node:5312) UnhandledPromiseRejectionWarning: TypeError: MessagePort was found in message but not listed in transferList
    at new Worker (internal/worker.js:170:17)
    at SassWorkerImplementation.createWorker (C:UsersshailiacademiaApp1node_modules@angular-devkitbuild-angularsrcsasssass-service.js:96:24)
    at SassWorkerImplementation.render (C:UsersshailiacademiaApp1node_modules@angular-devkitbuild-angularsrcsasssass-service.js:62:40)
    at Object.loader (C:UsersshailiacademiaApp1node_modulessass-loaderdistindex.js:46:3)
(node:5312) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5312) [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.
(node:5312) UnhandledPromiseRejectionWarning: TypeError: MessagePort was found in message but not listed in transferList
    at new Worker (internal/worker.js:170:17)
    at SassWorkerImplementation.createWorker (C:UsersshailiacademiaApp1node_modules@angular-devkitbuild-angularsrcsasssass-service.js:96:24)
    at SassWorkerImplementation.render (C:UsersshailiacademiaApp1node_modules@angular-devkitbuild-angularsrcsasssass-service.js:62:40)
    at Object.loader (C:UsersshailiacademiaApp1node_modulessass-loaderdistindex.js:46:3)
(node:5312) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
/ Generating browser application bundles (phase: building)...

回答

最新版本的 Angular CLI (12.0.1) 不支持低于 12.20 版本的 Node。

解决方案

将您的 Node 版本更新到最新的稳定版本

  • 您应该选择标记为 LTS 的版本,在撰写本文时该版本在 14.xx 范围内。

解决方法

仅在由于某种原因完全无法更新 Node 版本时才执行此操作

添加node-sass到您的项目 devDependencies 直到您能够更新您的节点版本。

npm i -save-dev node-sass
yarn add -D node-sass

你应该小心这个解决方法,因为 node-sass 很快就会被弃用。


以上是为我的第一个Angular应用程序运行“ngserve”时出错的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>