'An unhandled exception occurred: Invalid or unexpected token

I keep getting the following error after i run ng serve:

An unhandled exception occurred: Invalid or unexpected token
See "\mypc_path\AppData\Local\Temp\ng-Aij37E\angular-errors.log" for further details.

This is what's inside angular-errors.log:


[error] \myproject_path\node_modules\postcss-selector-parser\dist\selectors\combinator.js:1
��I=]8����"q�y-L@�]��~U�w@"��^ٮw'��b�


SyntaxError: Invalid or unexpected token
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (E:\Attuali\wherescrypto\node_modules\postcss-selector-parser\dist\parser.js:26:42)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)

I tried many things suggested online like:

  • Switching from yarn to npm (and back);
  • Deleting my current node_modules folder and running again npm i and yarn (not together, one by one);
  • Tried updating Node.js, NPM and Yarn;

I made an angular project from scratch, there are few libraries. The ones I installed are ngx-bootstrap-icons and @angular/fire

Any suggestion that can help?

Edit

Forgot to mention that I also tried to uninstall ngx-bootstrap-icons library. I still get the same error.

Edit 2

I was digging around the issue and I noticed this inside node_modules/postcss-selector-parser/dist/selectors/combinator.js:

��I=]8����"q�y-L@�]��~U�w@"��^ٮw'��b�
X�bz��=��| ��g�.��;{�
�g��Y�E"{9%�U�)���� "$3WD�I��LwK4��};�����F�v��.e�������
w
��Zg�vX$n]��    �c��_��n�?W�����SA�y�HdM�ä@�II��o d3_�n��f��u��&�����$�*v�{�6����}{WȽr/��N1Ë�*Rb�:��&�J�kx��ծ�T�R�ԶX�Β����,��j{��
�2���䆕�H�����S��>)W4��c�:�r�ez���f�W�~��Թ�2u�4!8=��h�s�V�M�$���ܹ�^����m��r#����v&�I
I?�n�%�BE����/0�������l�E�e���#���yE�����
a�Ի�a�)�y�Lޑ5Q��ʏ�|m���\HX#'_*�\��tFV=�C�U�I�qxZ�+v��$��x�!�\���������0lY�b2n�e�%#������"?t"�V��K^a#ׂ���
�3�,E�x ��+���P;fm,�*g1*V�x�vN��a��"M�(ϝ5s����fe1�G���\�c*&�]�j���]�"�!d���íP

That's too weird for me guys.



Solution 1:[1]

The old "delete node_modules and re-run npm i" trick worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 leila-m