2

I've searched all the web but find not relevant solution. I've uninstalled both @angular/cli and node.js, cleared cache and reinstalled the latest version for the two both as an admin and non-admin yet no result. Below is the error message:

ERROR in ./node_modules/core-js/modules/es6.regexp.exec.js 1:2 Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
i 「wdm」: Failed to compile.

Sometimes it brings this after working on a particular project thereby causing me not to continue it. I create another one and it might even not compile at all. I've created several projects now and all I get is this error during compilation.

I also noticed that it's only when I create a new Angular project while connected to the internet will it create else it will not and even stayed longer than expected during the creation.

halfer
  • 19,824
  • 17
  • 99
  • 186
Olawale Oladiran
  • 561
  • 2
  • 11
  • 19

6 Answers6

2

first remove node module and Uninstall the node

reinstall the application angular.io with globally than

npm install -g @angular/cli

1

In your project directory try to run ng update --all --force

Santosh Anand
  • 1,230
  • 8
  • 13
1

Delete node_modules folder and try again npm install

kalehmann
  • 4,821
  • 6
  • 26
  • 36
Pavel
  • 111
  • 2
  • 12
1

I had the same issue this morning and I was able to solve it. Follow these steps:

  1. Uninstall Node by using an app cleaner eg IObit Uninstaller Pro (The pro version will delete all folders associated with node eg npm, npm-cache. Also scan for those folders in case there are still some few leftovers.)

  2. Restart your pc.

  3. Go over to Nodejs.org and download Node 14.16, not the latest version. The latest is Node 14.17.

  4. Install Node which you downloaded.

  5. Launch CMD.

  6. Run npm i.

  7. After that, run npm i -g @angular/cli. This will install angular/cli 12.0.1 which is compatible with your version of Node.

  8. Create a new angular project by running the command: ng new new-project

  9. After successful install, change directory to your new created directory and run the command: ng serve --o

All those "failed to compile" errors wiil never happen again and your browser would display your web project.

The latest version of node is very buggy and I have actually relayed the matter to the nodejs developers community, commended them for the good job they do BUT asked them to get their acts together. I have lost so many projects due bugs which brought many issues similar to this.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Andrecon
  • 113
  • 2
  • 12
0

so simple: just update core-js from this simple command:

npm i core-js

no need to remove modules or reinstall or any of that

Nasr Galal
  • 31
  • 6
0

had the same issue

Reinstall Node.js

give Node folder access in Ransomware protection

gihan22603
  • 11
  • 3
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32622918) – Shea Hunter Belsky Sep 07 '22 at 18:12