[英]An unhandled exception occurred: Invalid or unexpected token
I keep getting the following error after i run ng serve
:运行
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
:这是
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:我尝试了许多在线建议的方法,例如:
node_modules
folder and running again npm i
and yarn
(not together, one by one);node_modules
文件夹并再次运行npm i
和yarn
(不一起,一一); I made an angular project from scratch, there are few libraries.我从头开始做了一个 angular 项目,库很少。 The ones I installed are
ngx-bootstrap-icons
and @angular/fire
我安装的是
ngx-bootstrap-icons
和@angular/fire
Any suggestion that can help?有什么可以帮助的建议吗?
Forgot to mention that I also tried to uninstall ngx-bootstrap-icons library.忘了提我还尝试卸载 ngx-bootstrap-icons 库。 I still get the same error.
我仍然得到同样的错误。
I was digging around the issue and I noticed this inside node_modules/postcss-selector-parser/dist/selectors/combinator.js
:我正在研究这个问题,我在
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.这对我来说太奇怪了伙计们。
I think I solved the issue, but it's not completely "clean".我想我解决了这个问题,但它并不完全“干净”。
After I saw that combinator.js was corrupted, I found the repository folder of the official library.看到combinator.js损坏后,我找到了官方库的repository文件夹。
I copied the code and pasted it by converting the import and exports, and now my combinator.js
is like this:我复制代码并通过转换导入和导出粘贴,现在我的
combinator.js
是这样的:
const Node = require('./node');
const { COMBINATOR } = require('./types');
class Combinator extends Node {
constructor (opts) {
super(opts);
this.type = COMBINATOR;
}
}
exports["default"] = Combinator;
module.exports = exports.default;
Now, when I do ng serve
, it compiles it correctly.现在,当我做
ng serve
时,它会正确编译它。 Still, that files is not supposed to be corrupted in the origin.尽管如此,该文件不应该在原始文件中损坏。 That's weird.
这很奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.