angulartypescriptwebpackng-upgrade

Uncaught SyntaxError: Unexpected token ! in vendors.bundle.js 174


I have a project in angularjs that i want to upgrade. So i installed ng-upgrade and got it set up, but when i ran the program i got this error:

Uncaught SyntaxError: Unexpected token ! vendors.bundle.js 174

I am new to webpack, what should i do?

I don't understand the problem and nobody seems to have encountered it before me. I haven't changed anything in webpack.config.js, just installed everything so i have no idea how it changed vendors.bundle.js.

Here ar my ts loader configuration in webpack.config.js

rules: [
    {
        test: /\.tsx?$/,
        loader: "awesome-typescript-loader"
    },
    {
        test: /\.js$/,
        enforce: "pre",
        loader: "source-map-loader"
    },

Main.ts:

import 'zone.js';
import 'reflect-metadata';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { setAngularLib } from '@angular/upgrade/static';
import * as angular from 'angular';

import { AppModule } from './app.module';

setAngularLib(angular);
platformBrowserDynamic().bootstrapModule(AppModule);

app.module.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';

@ngModule({
    imports: [
        BrowserModule,
        UpgradeModule
    ]
})
export class AppModule {
    constructor(private upgrade: UpgradeModule) {}

    ngDoBootstrap() {
        this.upgrade.bootstrap(document.documentElement, ["spp"], {strictDi: true});
    }
}

Icant seem to find any problems with the code, so i expect it to just show the thml.


Solution

  • i accidently installed @angular/core before its dependencies so didn't install, to fix this i just had to reinstall @angular/core.