每当我尝试通过在cmd中执行以下命令来运行webpack时
root-path>node-modules\.bin\webpack
我收到以下错误:
app.module.ts中@NgModule上的意外令牌。
似乎没有认出@符号。
我的应用的起点是main.ts.我正在使用角度js和角度5
创建混合应用程序main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module.ts';
import { environment } from './environments/environment.ts';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
app.module.ts
import 'zone.js';
import 'angular';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent } from "./app.component";
@NgModule({
imports: [
BrowserModule,
UpgradeModule
],
declarations: [
AppComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(private upgrade:UpgradeModule){}
ngDoBootstrap() {
this.upgrade.bootstrap(document.body, ['[config-module]'],{ strictDi: true });
}
}
webpack.config.js
const path = require('path');
//const ngtools = require('@ngtools/webpack');
module.exports = {
resolve: {
extensions: ['.ts', '.js'],
alias: {
"@angular/upgrade/static": "@angular/upgrade/bundles/upgrade-static.umd.js"
}
},
entry: './src/app/angular6/src/main.ts',
output: {
path: path.join(process.cwd(), 'dist'),
publicPath: 'dist/',
filename: "bundle.js"
},
module: {
rules: [
{
test: /.ts$/,
exclude:/(node_modules)/,
use:{
loader:"babel-loader",
options:{
presets:["env"]
}
}
}
]
}
};
tsconfig.js
{
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"mapRoot": "",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2017",
"dom"
],
"outDir": "lib",
"skipLibCheck": true,
"rootDir": "."
},