简体   繁体   English

发生未处理的异常:无效或意外的令牌

[英]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:我尝试了许多在线建议的方法,例如:

  • Switching from yarn to npm (and back);从纱线切换到 npm(和返回);
  • Deleting my current node_modules folder and running again npm i and yarn (not together, one by one);删除我当前的node_modules文件夹并再次运行npm iyarn (不一起,一一);
  • Tried updating Node.js, NPM and Yarn;尝试更新 Node.js、NPM 和 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?有什么可以帮助的建议吗?

Edit编辑

Forgot to mention that I also tried to uninstall ngx-bootstrap-icons library.忘了提我还尝试卸载 ngx-bootstrap-icons 库。 I still get the same error.我仍然得到同样的错误。

Edit 2编辑 2

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.

相关问题 ng test 和 ng serve 失败,并显示“发生未处理的异常:无效或意外的令牌” - ng test and ng serve fails with "An unhandled exception occurred: Invalid or unexpected token" 发生未处理的异常:意外的值“HeaderModule”。 请添加@NgModule 注释 - An unhandled exception occurred: Unexpected value 'HeaderModule'. Please add a @NgModule annotation 发生未处理的异常:NGCC 失败 - An unhandled exception occurred: NGCC failed 发生未处理的异常:无效的 lint 配置。 在 Angular 12 中将 Tslint 迁移到 eslint 后没有任何 lint - An unhandled exception occurred: invalid lint configuration. Nothing to lint after migrating Tslint to eslint in Angular 12 发生未处理的异常:工作区中未设置配置“dev” - An unhandled exception occurred: Configuration 'dev' is not set in the workspace Anuglar - npm 审计修复 - 发生未处理的异常 - Anuglar - npm audit fix - unhandled exception occurred 发生未处理的异常:需要缺少<target>元素 - An unhandled exception occurred: Missing required <target> element 在 .netcore 中处理请求时发生未处理的异常 - An unhandled exception occurred while processing the request in .netcore 发生未处理的异常:ENOENT:没有这样的文件或目录,lstat - An unhandled exception occurred: ENOENT: no such file or directory, lstat 发生未处理的异常:找不到模块“./browsers”- - An unhandled exception occurred: Cannot find module './browsers' -
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM