Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error while running "ng serve" for my first angular application

Message&trace:

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:\Users\shail\iacademiaApp1\node_modules\@angular-devkit\build-angular\src\sass\sass-service.js:96:24)
    at SassWorkerImplementation.render (C:\Users\shail\iacademiaApp1\node_modules\@angular-devkit\build-angular\src\sass\sass-service.js:62:40)
    at Object.loader (C:\Users\shail\iacademiaApp1\node_modules\sass-loader\dist\index.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:\Users\shail\iacademiaApp1\node_modules\@angular-devkit\build-angular\src\sass\sass-service.js:96:24)
    at SassWorkerImplementation.render (C:\Users\shail\iacademiaApp1\node_modules\@angular-devkit\build-angular\src\sass\sass-service.js:62:40)
    at Object.loader (C:\Users\shail\iacademiaApp1\node_modules\sass-loader\dist\index.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)...
like image 223
Shail Patel Avatar asked May 20 '21 08:05

Shail Patel


People also ask

How do you solve the error Serve command requires to run in Angular project but a project definition could not be found?

This error often occurs when a project you are running is not an Angular project. It may also be the case when you download an Angular project but do not have latest dependencies installed on your machine. Installing latest dependencies should fix the problem.

What is difference between ng serve and npm start?

npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server. js. It seems like ng serve starts the embedded server whereas npm start starts the Node servers.

Why my ng serve is not working?

To solve the error "ng: command not found", install the angular cli package globally by running npm install -g @angular/cli@latest and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.

What happens when Ng serve command is executed?

From the docs: The CLI supports running a live browser reload experience to users by running ng serve. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via webpack-dev-server.


1 Answers

The latest version of the Angular CLI (12.0.1) does not support Node below version 12.20.

Solution

Update your version of Node to the latest stable version

  • You should pick the version marked LTS, which at the time of writing is in the 14.x.x range.

Workaround

Only do this if you for some reason are completely unable to update your Node version

Add node-sass to your project devDependencies until you are able to update your version of node.

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

You should be careful with this workaround, as node-sass is going to be deprecated soon.

like image 192
Mikkel Christensen Avatar answered Nov 06 '22 14:11

Mikkel Christensen