import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
Following is the full error:
0% compiling
Compiling @angular/core : es2015 as esm2015
10% building 3/3 modules 0 activeℹ 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: 404s will fallback to //index.html
chunk {main} main.js, main.js.map (main) 2.1 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 127 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 177 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 340 kB [initial] [rendered]
Date: 2020-03-25T14:38:50.300Z - Hash: 5926a3d885deed4ad147 - Time: 3212ms
ERROR in Cannot read property 'map' of undefined
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Failed to compile.
解决方案
On your chrome or your browser's debugger , select pause on caught exceptions. It will stop at this place where you are getting this error.
Better way to do it would be to enable source maps.
I am pretty sure the bundler that you are using would have support to generate javascript source maps. For angular I think you can find out how to enable source maps on the net, might be just a small config change. Enable it , build your application , run it on chrome and select pause on caught exceptions. It will stop at the exact line and it will show the file where this error has occured.
Don't forget to disable source maps for prod environments