我已将我们的应用程序从角度4更新为角度5,当我运行“yarn run start”命令时出现错误错误TS2307:找不到模块'./compiled/app/app.module.ngfactory'。/main .TS。
我们正在使用gulp和webpack。
在webpack配置中,我使用AngularCompilerPlugin:
const AotPlugin = require('@ ngtools / webpack')。AngularCompilerPlugin;
这是packages.json文件
{
"name": "App",
"version": "1.5.0",
"scripts": {
"start": "gulp build:dev",
"test": "gulp test",
"build": "gulp build",
"postinstall": "typings install"
},
"engines": {
"node": "6.10.3",
"npm": "4.0.5"
},
"license": "LicenseRef-LICENSE",
"private": true,
"repository": {
"url": "git+ssh://gitolite@git:App"
},
"dependencies": {
"@angular/animations": "5.0.0",
"@angular/common": "5.0.0",
"@angular/compiler": "5.0.0",
"@angular/compiler-cli": "5.0.0",
"@angular/core": "5.0.0",
"@angular/forms": "5.0.0",
"@angular/http": "5.0.0",
"@angular/platform-browser": "5.0.0",
"@angular/platform-browser-dynamic": "5.0.0",
"@angular/platform-server": "5.0.0",
"@angular/router": "5.0.0",
"@ngx-translate/core": "8.0.0",
"@ngx-translate/http-loader": "2.0.0",
"@types/file-saver": "1.3.0",
"angular2-infinite-scroll": "0.3.4",
"core-js": "2.5.1",
"file-saver": "1.3.3",
"jasmine": "2.8.0",
"jstz": "1.0.9",
"moment": "2.18.1",
"moment-timezone": "0.5.13",
"ngx-bootstrap": "2.0.0-beta.8",
"reflect-metadata": "0.1.10",
"rxjs": "5.5.2",
"xlsx": "0.11.7",
"zone.js": "0.8.5"
},
"devDependencies": {
"@ngtools/webpack": "1.8.0",
"autoprefixer": "6.7.6",
"bootstrap-sass": "3.3.7",
"custom-tslint-formatters": "2.0.0",
"del": "2.2.2",
"enhanced-resolve": "3.3.0",
"gulp": "3.9.1",
"gulp-add-src": "0.2.0",
"gulp-cache-bust": "1.1.0",
"gulp-exec": "2.1.3",
"gulp-htmlmin": "3.0.0",
"gulp-if": "2.0.2",
"gulp-ignore": "2.0.2",
"gulp-imagemin": "3.1.1",
"gulp-jsonminify": "1.0.0",
"gulp-postcss": "6.3.0",
"gulp-preprocess": "2.0.0",
"gulp-sass": "3.1.0",
"gulp-sourcemaps": "2.4.1",
"gulp-svg-sprite": "1.3.6",
"gulp-tslint": "7.1.0",
"gulp-util": "3.0.8",
"jasmine-core": "2.5.2",
"json-loader": "0.5.4",
"karma": "1.5.0",
"karma-chrome-launcher": "2.0.0",
"karma-ie-launcher": "1.0.0",
"karma-jasmine": "1.1.0",
"karma-mocha-reporter": "2.2.2",
"karma-sourcemap-loader": "0.3.7",
"karma-typescript": "3.0.8",
"karma-typescript-es6-transform": "1.0.2",
"karma-webpack": "2.0.2",
"postcss-loader": "1.3.3",
"postcss-scss": "0.4.1",
"precss": "1.4.0",
"raw-loader": "0.5.1",
"run-sequence": "1.2.2",
"sass-loader": "6.0.3",
"ts-loader": "2.0.1",
"tslint": "4.5.1",
"typescript": "2.4.2",
"typings": "2.1.0",
"webpack": "2.2.1"
}
}
main.ts
import { enableProdMode } from "@angular/core";
import { platformBrowser } from "@angular/platform-browser";
import { AppModuleNgFactory } from "./compiled/app/app.module.ngfactory";
if (process.env.ENV === "production") {
enableProdMode();
}
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
也是tsconfig.json文件
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"outDir": "./compiled",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"typeRoots": [
"node_modules/@types/"
]
},
"exclude": [
"node_modules"
],
"angularCompilerOptions": {
"genDir": "./compiled",
"skipMetadataEmit" : true
}
}
谢谢你