找不到模块:错误:无法解析“ ./$$_gendir/app/app.app.module.ngfactory”

布莱恩·伯松

就在昨天,我的代码运行良好,未对应用程序模块进行任何更改,今天使用“ ng build --prod”时,出现此错误。我知道这与更改无关,当我拉旧的分支时会遇到相同的错误。我不知道该怎么办,建议您更新每个软件包,但是即使在我仍然遇到相同的错误之后。甚至不确定你们是否可以提供帮助,但这是我的app.module:

import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';

import {AppComponent} from './app.component';
import {LoginComponent} from './login/login.component';
import {CompareComponent} from './compare/compare.component';
import {RouterModule} from "@angular/router";
import {CompareCardComponent} from './compare/compare-card/compare-card.component';
import {LayoutComponent} from './layout/layout.component';
import {CompareValuePipe} from "./compare/compare-card/compare-card.pipe";
import {HomeComponent} from './home/home.component';
import {NewLocationComponent} from './new-location/new-location.component';
import {SignupComponent} from './signup/signup.component';
import {ValidateMe} from "./shared/me.suite/validate.me/validate.me";
import {TagsComponent} from './tags/tags.component';
import {GoogleplaceDirective} from './third-party/angular2-google-map-auto-complete/directives/googleplace.directive';
import { LoaderComponent } from './shared/loader/loader.component';
import { AlertComponent } from './shared/alert/alert.component';
import {Angulartics2GoogleAnalytics, Angulartics2Module} from "angulartics2";
import { OverallPipe } from './compare/overall.pipe';
import {InteractiveComponent} from "./question/interactive/interactive.component";
import { FormComponent } from './question/form/form.component';
import { KpiDescComponent } from './compare/kpi-desc/kpi-desc.component';
import {HashLocationStrategy, Location, LocationStrategy} from "@angular/common";
import {AccountApi} from "./services/account-api.service";
import {SettingsApi} from "./services/settings-api.service";
import {DataApi} from "./services/data-api.service";
import { ZeezorInfoComponent } from './zeezor-info/zeezor-info.component';

const ROUTES = [
    {path: '', redirectTo: '/home', pathMatch: 'full'},
    {path: 'compare', component: CompareComponent},
    {path: 'new', component: NewLocationComponent},
    {path: 'tags', component: TagsComponent},
    {path: 'interactive', component: InteractiveComponent},
    {path: 'form', component: FormComponent},
    {path: 'login', component: LoginComponent},
    {path: 'signup', component: SignupComponent},
    {path: 'home', component: HomeComponent},
    {path: '**', component: HomeComponent}
];

@NgModule({
    declarations: [
        LayoutComponent,
        AppComponent,
        LoginComponent,
        CompareComponent,
        CompareCardComponent,
        CompareValuePipe,
        InteractiveComponent,
        HomeComponent,
        NewLocationComponent,
        SignupComponent,
        ValidateMe,
        TagsComponent,
        GoogleplaceDirective,
        LoaderComponent,
        AlertComponent,
        OverallPipe,
        FormComponent,
        KpiDescComponent,
        ZeezorInfoComponent
    ],
    imports: [
        BrowserModule,
        FormsModule,
        HttpModule,
        RouterModule.forRoot(ROUTES),
        Angulartics2Module.forRoot([ Angulartics2GoogleAnalytics ])
    ],
    providers: [AccountApi, DataApi, SettingsApi, Location, {provide: LocationStrategy, useClass: HashLocationStrategy}],
    bootstrap: [AppComponent]
})
export class AppModule {
    constructor(){
        let style = document.createElement('link');
        style.rel = "stylesheet";
        style.href = SettingsApi.styleEndpoint;
        window.document.head.appendChild(style);
        console.log(navigator.userAgent);
    }
}

Package.json

{
  "name": "stack-up",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "compile": "ng build --environment=mobile --output-path ../mobile/www/",
    "compile:prod": "ng build --environment=mobile --target=production --output-path ../mobile/www/",
    "docker": "ng build --environment=docker",
    "local": "ng serve --environment=local",
    "dev": "ng build --environment=dev",
    "prod": "ng build --environment=prod --target=production --output-path /var/www/html/"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "angular2-jwt": "^0.2.2",
    "angular2-social-login": "^2.1.0",
    "angulartics2": "^2.2.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "tslint": "^3.15.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.31",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.0"
  }
}
布莱恩·沃克(Brian Walker)

昨天我遇到了类似的问题(相同的错误消息),并根据以下angular-cli问题进行了修复:

https://github.com/angular/angular-cli/issues/7125

解决方法是将其固定到我的package.json中的enhanced-resolve版本3.3.0,删除node_modules,运行npm install,然后再次构建。这似乎已经解决了问题线程中某些人的问题。

较新版本的Enhanced-Resolve似乎引起了一些问题。

如果仍然无法运行,请通过运行确保您具有正确的增强解析版本npm ls enhanced-resolve

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

找不到模块:错误:无法解析'./$$_gendir/app/app.app.module.ngfactory'

找不到模块:错误:在以下位置无法解析“ ./$$_gendir/app/app.app.module.ngfactory”

找不到模块:错误:无法解析“ ./app/app.module.ngfactory”

找不到模块:错误:无法解析“./app.module.ngfactory” - 离子 3,角度 5

找不到模块“ ./app.module.ngfactory”

角度AOT和汇总-无法解析'app.module.ngfactory'

错误:无法解析“ C:\ projects \ Project-CMS \ Project.Web \ src”中的“ ./app/app.module.ngfactory”

角度生产构建错误为什么我得到./src/app/app.app.module.ngfactory.js

[加载程序]中的错误找不到模块'./app.component.ngfactory'

Angular 8 使用 Ivy module.ngfactory 找不到

错误:找不到模块“ app / MyComponent / MyComponent.module”错误:找不到模块

角8.2 +火力地堡:`ERROR近纳克构建的`年底/ src目录/应用/ app.module.ngfactory.js`错误--prod`失败的过程

Angular 2单元测试-出现错误无法加载'ng:///DynamicTestModule/module.ngfactory.js'

app.module错误,找不到名称

找不到模块:错误:无法解析“ / home / user / Desktop / my_app / src”中的“ ./app”

webpack-找不到模块:错误:无法解析“ ./src/app/app.component.html”

错误[ERR_MODULE_NOT_FOUND]:找不到从build \ server.js导入的模块“ build \ app”

例外:未捕获(承诺):错误:找不到模块“ app / home / home.module”

找不到模块:错误:无法在'C:\ MAMP \ htdocs \ AngularFrontEnd \ src \ app'中解析'rxjs / Rx'

找不到模块:错误:无法在'/ app'中解析'@ angular / flex-layout'

找不到模块:无法解析“*.module.css”

找不到 ./src/app/svg.component.ts 模块中的错误:错误:无法解析“./svg.component.svg”

找不到模块:错误:无法解析“ / Users / jonathankuhl / Documents / Programming / node js / sandbox / webpack-app”中的“ bundle.js”

找不到模块:错误:无法解析'/ opt / lampp / htdocs / angular-testing-app / node_modules / jwa'中的'crypto'

角5:src / app / app.module.ts(24,24)中的错误:错误TS2307:找不到模块'https'

错误:找不到模块 'babel-preset-react' - 如果要解析“react”,请使用“module:react”

Angular 2提前编译器找不到ngfactory吗?

找不到模块:无法在“ / home / n / MyWork / my-app / src”中解析“ ./clock”

找不到模块:无法解析“ ... / score-board-app / src / components”中的“ ./components/player”