标签: angular-compiler

Angular 9 - NGCC 因未处理的异常而失败

在将依赖项升级到 Angular 9(并执行必要的代码更改)后构建应用程序会引发错误:

编译@angular/animations : es2015 as esm2015 编译@angular/animations : es2015 as esm2015 编译@angular/core : es2015 as esm2015 编译@angular/core : es2015 as esm2015 as esm2015
编译
错误:@angular es102015 #5:类型错误:无法读取 null 的属性“fileName”

然后继续抛出以下错误:

编译@angular/core : es2015 as esm2015 编译@angular/compiler/testing : es2015 as esm2015 编译@angular/core : es2015 as esm2015
错误:试图用anonybyakts编写node_modules/@angular/core.cc_ivyakts ngcc 备份文件,但它已经存在,所以不写,也不备份,node_modules/@angular/core/core.d.ts。

这个错误可能是因为两个或多个入口点重叠,并且 ngcc 被要求不止一次处理一些文件。
您应该检查此包中的其他入口点并设置配置以忽略您未使用的任何入口点。

将@angular/core : es2015 编译为 esm2015 发生未处理的异常:NGCC 失败。

ivy typescript angular angular-compiler

63
推荐指数
8
解决办法
12万
查看次数

_lazy_route_resource延迟命名空间对象

我正在使用角度编译器: const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;

使用这些编译器选项:

"angularCompilerOptions": {
"genDir": "./build/compiled",
"outDir": "./build/compiled",
"skipMetadataEmit": true,
"debug": true},
Run Code Online (Sandbox Code Playgroud)

我的package.json的相关部分是:

"@ngtools/webpack": "^6.0.0",
"@angular/router": "^5.2.0",
"webpack": "4.8.3",
"webpack-cli": "2.1.4",
Run Code Online (Sandbox Code Playgroud)

而我的angularCompilerPlugin配置是:

new AngularCompilerPlugin({
  tsConfigPath: 'path-to-tsconfig.webpack.json',
  entryModule: 'path-to-app.module#AppModule',
  sourceMap: true
}),
Run Code Online (Sandbox Code Playgroud)

通过这些配置,我得到:

ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve 'path-/alerts/module.ngfactory.js' in 'path-to-app-folder/$$_lazy_route_resource'
 @ ./$$_lazy_route_resource lazy namespace object
 @ ./node_modules/@angular/core/esm5/core.js
 @ multi core-js/shim classlist.js reflect-metadata zone.js/dist/zone jquery/dist/jquery rxjs/Rx lodash jquery.panzoom moment moment-timezone @angular/common @angular/core @angular/http @angular/router @angular/forms semantic
Run Code Online (Sandbox Code Playgroud)

请任何指示或帮助.

angular-compiler angular-aot angular5 webpack-4

10
推荐指数
1
解决办法
3193
查看次数

无法读取null的属性'config'

我是angular2的新手.我已下载angular 2项目并尝试设置.我安装了角度cli 1.0.0-rc.2,当我正在服务时,它显示以下错误:

无法读取属性'config'的null TypeError:无法在Class.run(D:\ Sumit\AgulaNew\admin \node_modules\@angular\cli\tasks\serve.js:22:63)中读取null的属性'config' check_port_1.checkPort.then.port(D:\ Sumit\AgulaNew\admin \node_modules\@angular\cli\commands\serve.js:103:26)at at process._tickCallback(internal/process/next_tick.js:188: 7)

angular-cli angular angular-compiler

6
推荐指数
2
解决办法
6987
查看次数

Angular 中动态编译的延迟加载动态路由导致“不安全评估”错误

在应用内容安全策略后,在 angular 应用程序的 index.html 文件中,应用程序给出了“unsafe-eval”控制台错误,如下所示 -

core.js:4442 ERROR Error: Uncaught (in promise): EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self'".

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self'".

    at new Function (<anonymous>)
    at JitEvaluator.evaluateCode (compiler.js:6740)
    at JitEvaluator.evaluateStatements (compiler.js:6714)
    at CompilerFacadeImpl.jitExpression (compiler.js:19300)
    at CompilerFacadeImpl.compileNgModule (compiler.js:19238) …
Run Code Online (Sandbox Code Playgroud)

ivy content-security-policy angular angular-compiler angular-jit

6
推荐指数
1
解决办法
560
查看次数

*.ngsummary.json 的目的是什么

我刚刚学习AOTngc等运行后ngc我看到很多的*.ngsummary.json(在src文件夹旁*.ts的文件)。

它们是为了什么?

angular-compiler-cli angular angular-compiler

5
推荐指数
1
解决办法
1904
查看次数

Angular - useFactory - 不支持错误函数调用。考虑使用对导出函数的引用替换函数或 lambda

我使用 Angular AOT 编译器版本 4.1.3

我有一个组件库,它导出一个工厂方法,然后用于提供服务:

export function libServiceFactory(itemId: string) {
  return (http: Http): LibService => {
    return new LibService(http, itemId);
  };
};
Run Code Online (Sandbox Code Playgroud)

编译库ngc成功。

然后导入编译好的库,我LibServiceFactory在网站的 AppModule 中使用:

providers: [
  { provide: SERVICE_TOKEN, useFactory: libServiceFactory('foo'), deps: [Http] }
],
Run Code Online (Sandbox Code Playgroud)

编译网站ng build我收到以下错误:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 5:10 in the …
Run Code Online (Sandbox Code Playgroud)

angular-factory angular angular-compiler angular-aot

5
推荐指数
1
解决办法
1752
查看次数

非法状态:无法加载指令NgClass的摘要

ngc在我的模块上运行时,它过去经常使用angular 4.4.3(和编译器4.4.3)可以正常工作。现在,我升级到5.0.0(包括angular和编译器),并且出现以下错误:

错误:非法状态:无法将指令NgClass的摘要加载到[...] / node_modules/@angular/common/common.d.ts中。

我的tsconfig.json文件如下所示:

{
  "compilerOptions": {
    "baseUrl": ".",
    "declaration": true,
    "stripInternal": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "module": "es2015",
    "moduleResolution": "node",
    "outDir": "[...]/",
    "paths": {...},
    "rootDir": "[...]/plugins/",
    "target": "es5",
    "skipLibCheck": true,
    "lib": [
      "es2015",
      "dom"
    ],
    "sourceMap": true,
    "inlineSources": true,
    "noImplicitAny": true
  },
  "files": [
    "[...]/plugins/users/index.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我不知道是什么原因导致我尝试编译的文件出现问题。我到处都看到了类似的错误,但与普通模块没有直接关系。发布示例以重现错误是很困难的,因为其他模块上不会发生

编辑1:

我的设置如下:一个模块MyModuleA成功构建,MyModuleB使用MyModuleA该模块则不构建。

@NgModule({
  imports: [
    CommonModule,
    IonicModule,
    TranslateModule.forChild()
  ]
})
export class MyModuleA {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule: MyModuleA, …
Run Code Online (Sandbox Code Playgroud)

angular angular-compiler

5
推荐指数
1
解决办法
747
查看次数

“ngcc”未被识别为内部或外部命令

运行命令npm run ngcc会引发错误'ngcc' is not recognized as an internal or external command

package.json

{
  "scripts": {
    "ngcc": "ngcc"
    ...
  },
  "dependencies": {
    "@angular-extensions/elements": "^9.3.0",
    "@angular/animations": "~9.1.0",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    "@angular/core": "~9.1.0",
    "@angular/elements": "~9.1.0",
    "@angular/forms": "~9.1.0",
    "@angular/platform-browser": "~9.1.0",
    "@angular/platform-browser-dynamic": "~9.1.0",
    "@angular/router": "~9.1.0",
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)

anuglar-compiler 和其他包的版本是否有任何不匹配?无法找到问题的根本原因。有人可以帮忙吗?

angular-compiler-cli angular angular-compiler

5
推荐指数
1
解决办法
2554
查看次数

Angular v13 中动态/运行时模块的 Angular 编译器 API 替换

我们使用编译器中的这个函数compileModuleAndAllComponentsAsync来创建动态/运行时模块

该编译器在 Angular v13 中已弃用

是否有人有类似的(动态/运行时模块)用例并已成功替换CompilerAPI?

angular angular-compiler angular13

5
推荐指数
0
解决办法
334
查看次数

如何安装正确版本的 @Angular-eslint/schematic 以匹配我的 Angular 编译器?

我正在使用 npm v 8.11.0。我在 package.json 文件中定义了这些依赖项

\n
"@angular/compiler": "^13.2.6",\n"@angular/core": "^13.2.6",\n
Run Code Online (Sandbox Code Playgroud)\n

我想让“ng lint”运行,但显然我需要运行迁移,所以我运行

\n
$ ng add @angular-eslint/schematics\nYour global Angular CLI version (14.0.5) is greater than your local version (13.2.6). The local Angular CLI version is used.\n\nTo disable this warning use "ng config -g cli.warnings.versionMismatch false".\n\xe2\x84\xb9 Using package manager: npm\n\xe2\x9c\x94 Found compatible package version: @angular-eslint/schematics@13.5.0.\n\xe2\x9c\x94 Package information loaded.\n\nThe package @angular-eslint/schematics@13.5.0 will be installed and executed.\nWould you like to proceed? Yes\nnpm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.\nnpm …
Run Code Online (Sandbox Code Playgroud)

lint angular angular-compiler angular13

5
推荐指数
1
解决办法
1万
查看次数