gpt4 book ai didi

angular - Uncaught TypeError : ace. acequire 不是函数

转载 作者:行者123 更新时间:2023-12-05 07:21:34 27 4
gpt4 key购买 nike

我已将 ng2-ace-editor 用于其中一个组件,并尝试使用 ng test 命令运行测试用例。但由于某些原因,它抛出了 Uncaught TypeError: ace.acequire is not a function 错误。

这是我的 .spec.ts 文件代码:

import { NewModule } from './new.module';
import {AceEditorModule} from 'ng2-ace-editor';
import 'brace';
import 'brace/mode/json';
import 'brace/ext/language_tools';

describe('NewModule', () => {
let component: NewModule;
let fixture: ComponentFixture<Module>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ MaterialModule, ReactiveFormsModule, FormsModule, HttpModule,
HttpClientTestingModule, RouterTestingModule, BrowserAnimationsModule,
AceEditorModule
],
declarations: [ NewModule ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(NewModule);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

我不知道如何解决这个问题。在某个地方我知道大括号是依赖项并且需要安装它。我确实安装了支架,但它不起作用。我尝试在 angular.json 的脚本中提供依赖项文件,但它不起作用。

代码如下:

"scripts": [
"node_modules/ace-builds/src-min/ace.js",
"node_modules/ace-builds/src-min/ext-language_tools.js",
"node_modules/ace-builds/src-min/mode-javascript.js",
"node_modules/ace-builds/src-min/mode-typescript.js",
"node_modules/ace-builds/src-min/mode-json.js",
"node_modules/ace-builds/src-min/theme-eclipse.js"
]

因为这个其他规范文件没有运行, karma 抛出下面提到的错误。请建议我需要做什么。

Uncaught TypeError: ace.acequire is not a function
at language_tools.js:1954
at Object../node_modules/brace/ext/language_tools.js (language_tools.js:1955)
at __webpack_require__ (bootstrap:76)

最佳答案

我遇到了同样的问题,并通过在 xx.component .ts 文件而不是 .spec.ts 文件中添加代码来修复它。

import 'brace';

关于angular - Uncaught TypeError : ace. acequire 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56834637/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com