【问题标题】:export 'ɵcmf' was not found in '@angular/core'在“@angular/core”中找不到导出“ɵcmf”
【发布时间】:2017-06-20 14:45:50
【问题描述】:

启动 webpack-dev-server 时会抛出以下警告:

WARNING in ./~/@angular/compiler/@angular/compiler.es5.js
11051:13-17 "export 'ɵcmf' was not found in '@angular/core'

WARNING in ./~/@angular/compiler/@angular/compiler.es5.js
11056:13-17 "export 'ɵmod' was not found in '@angular/core'

WARNING in ./~/@angular/compiler/@angular/compiler.es5.js
11061:13-17 "export 'ɵmpd' was not found in '@angular/core'

由于它只是一个警告,因此在尝试访问应用程序时仍会生成并提供输出

Uncaught TypeError: jit_val0 is not a function
    at eval (module.ngfactory.js? [sm]:1)
    at evalExpression (compiler.es5.js:26423)
    at jitStatements (compiler.es5.js:26435)
    at JitCompiler._compileModule (compiler.es5.js:26716)
    at compiler.es5.js:26655
    at Object.then (compiler.es5.js:1679)
    at JitCompiler._compileModuleAndComponents (compiler.es5.js:26653)
    at JitCompiler.compileModuleAsync (compiler.es5.js:26582)
    at PlatformRef_._bootstrapModuleWithZone (core.es5.js:4811)
    at PlatformRef_.bootstrapModule (core.es5.js:4797)
(anonymous) @ module.ngfactory.js? [sm]:1
evalExpression @ compiler.es5.js:26423
jitStatements @ compiler.es5.js:26435
JitCompiler._compileModule @ compiler.es5.js:26716
(anonymous) @ compiler.es5.js:26655
then @ compiler.es5.js:1679
JitCompiler._compileModuleAndComponents @ compiler.es5.js:26653
JitCompiler.compileModuleAsync @ compiler.es5.js:26582
PlatformRef_._bootstrapModuleWithZone @ core.es5.js:4811
PlatformRef_.bootstrapModule @ core.es5.js:4797
(anonymous) @ main.ts:12
__webpack_require__ @ bootstrap 91fab75…:54
(anonymous) @ main.bundle.js:20785
__webpack_require__ @ bootstrap 91fab75…:54
webpackJsonpCallback @ bootstrap 91fab75…:25
(anonymous) @ main.bundle.js:1

被抛出并且 Angular 没有成功引导。

【问题讨论】:

标签: angular webpack webpack-dev-server


【解决方案1】:

如果你运行“ng -v”,你是否在同一个版本中拥有 angular 的所有依赖项?

我遇到了完全相同的问题,当我执行该命令时,结果是:

@angular/cli: 1.0.1
node: 6.11.0
os: linux x64
@angular/animations: 4.2.3
@angular/common: 4.2.3
@angular/compiler: 4.2.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/platform-server: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.0.1
@angular/compiler-cli: 4.1.0

我更改了 package.json 并将所有依赖项设置为 4.2.3 版本,然后运行“rm -rf node_modules && npm install”,现在可以正常工作了!

【讨论】:

  • 实际上,在我的情况下,错误刚刚停止出现(可能是在我做了与您描述的类似的事情之后)。然而,这似乎是一个合理的解释。
  • 不幸的是,这对我不起作用。只有在尝试使用延迟加载模块时,我才会收到类似的错误:“TypeError: angular_core__WEBPACK_IMPORTED_MODULE_0_.ɵcmf is not a function at Module../src/main/webapp/src/app/my-模块/my-module.module.ngfactory.js (3.bundle.js:27)"
【解决方案2】:

我执行了以下步骤,一切正常。

npm install -S @angular/material @angular/cdk @angular/animations
npm uninstall @angular/core
npm install -S @angular/core

【讨论】:

    【解决方案3】:

    今天早上我遇到了同样的问题,我对昨天有效的代码进行了零更改。

    我刚刚重新安装了我的 node_modules,它为我修复了它。

    rm -rf node_modules && npm install 
    

    【讨论】:

      【解决方案4】:

      在我的情况下,问题是由于生成的 JS 包 (UTF-8) 和为这些包提供服务的 Tomcat (ISO-8859-1) 之间的字符编码不匹配造成的。只需将charset="UTF-8" 添加到加载捆绑包的<script> 标记即可解决问题。

      【讨论】:

        猜你喜欢
        • 2018-02-03
        • 2019-10-19
        • 1970-01-01
        • 2019-12-28
        • 2020-03-23
        • 1970-01-01
        • 1970-01-01
        • 2020-12-25
        • 1970-01-01
        相关资源
        最近更新 更多