我一直在尝试使用AOT进行构建(ng build --prod及其变体)。 但我现在收到以下错误:
> ./src/main.ts中的错误 找不到模块:错误:无法解析'C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ src'中的'./$$_gendir/app/app.module.ngfactory' 解决'C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ src'中的'./$$_gendir/app/app.module.ngfactory' 使用描述文件:C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ package.json(相对路径:./ src) 字段“浏览器”不包含有效的别名配置 使用描述文件后:C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ package.json(相对路径:./ src) 使用描述文件:C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ package.json(相对路径:./ src / $ _ yinir / app / app.module.ngfactory) 没有延期 字段“浏览器”不包含有效的别名配置 C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ src \ $$ _ gendir \ app \ app.module.ngfactory不存在 .TS 字段“浏览器”不包含有效的别名配置 C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ src \ $$ _ gendir \ app \ app.module.ngfactory.ts不存在 .js文件 字段“浏览器”不包含有效的别名配置 C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ src \ $$ _ gendir \ app \ app.module.ngfactory.js不存在 作为目录 C:\ Users \ TVDBF62 \ Documents \ SportClub2 \ sportclub-frontend \ src \ $$ _ gendir \ app \ app.module.ngfactory不存在 [C:\用户\ TVDBF62 \文件\ SportClub2 \ sportclub-前端\ SRC \ $$ _ gendir \应用\ app.module.ngfactory] [C:\用户\ TVDBF62 \文件\ SportClub2 \ sportclub-前端\ SRC \ $$ _ gendir \应用\ app.module.ngfactory.ts] [C:\用户\ TVDBF62 \文件\ SportClub2 \ sportclub-前端\ SRC \ $$ _ gendir \应用\ app.module.ngfactory.js] [C:\用户\ TVDBF62 \文件\ SportClub2 \ sportclub-前端\ SRC \ $$ _ gendir \应用\ app.module.ngfactory] @ ./src/main.ts 5:29-76 @ multi ./src/main.ts
这是我的package.json
{
"name": "R-SportClub",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --env=prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.4.6",
"@angular/cdk": "^2.0.0-beta.12",
"@angular/cli": "^1.4.7",
"@angular/common": "^4.4.6",
"@angular/compiler": "^4.4.6",
"@angular/compiler-cli": "^4.4.6",
"@angular/core": "^4.4.6",
"@angular/forms": "^4.4.6",
"@angular/http": "^4.4.6",
"@angular/material": "^2.0.0-beta.12",
"@angular/platform-browser": "^4.4.6",
"@angular/platform-browser-dynamic": "^4.4.6",
"@angular/router": "^4.4.6",
"angular-hammer": "^2.2.0",
"angular-in-memory-web-api": "^0.5.2",
"angular2-datetimepicker": "^1.1.1",
"core-js": "^2.4.1",
"enhanced-resolve": "^3.3.0",
"fullcalendar": "3.7.0",
"html-webpack-plugin": "^2.28.0",
"jquery": "^3.2.1",
"ng-fullcalendar": "^1.4.0",
"ng4-geoautocomplete": "^0.1.0",
"npm-install-all": "^1.1.21",
"rxjs": "5.4.2",
"ts-stream": "^1.0.1",
"typescript": "~2.3.3",
"webpack": "^3.10.0",
"zone.js": "^0.8.20"
},
"devDependencies": {
"@angular-devkit/schematics": "0.0.34",
"@angular/language-service": "^4.4.6",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/jquery": "^3.2.18",
"@types/node": "^6.0.96",
"codelyzer": "~3.2.0",
"html-webpack-plugin": "^2.28.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "^4.1.1",
"karma": "~1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.3",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"webpack": "^3.10.0"
},
"engines": {
"node": "8.6.0",
"npm": "5.5.1"
}
}
这是我的主要内容:
import {environment} from "./environments/environment";
import {enableProdMode} from "@angular/core";
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app/app.module";
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
我已经看到很多关于这个主题的问题,常见的答案是安装enhanced-resolve@3.3.0,但这对我不起作用。我已经尝试了一些其他答案,比如更新我的软件包,但这也没有用。我没有想法,还有其他人吗? 感谢