You may need an appropriate loader for dynamic imports after upgrade to Angular 8
🐞 bug report
Description
I've updated my Angular 7 app to Angular 8. It used the old Angular way dynamic imports. i've ran ng update @angular/cli @angular/core, everything was updated properly and it was using the new standard for dynamic imports, but app cannot now be opened. It breaks during the compile process. This might be webpack issue?
🔬 Minimal Reproduction
Updated to Angular 8 and this error is throwing.
🔥 Exception or Error
ERROR in ./src/app/app-routing.module.ts 8:28
Module parse failed: Unexpected token (8:28)
You may need an appropriate loader to handle this file type.
| {
| path: 'auth',
> loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule)
| },
| {
🌍 Your Environment
Angular Version:
Angular CLI: 8.0.0
Node: 10.13.0
OS: darwin x64
Angular: 8.0.0
@angular-devkit/architect 0.800.0
@angular-devkit/build-angular 0.800.0
@angular-devkit/build-optimizer 0.800.0
@angular-devkit/build-webpack 0.800.0
@angular-devkit/core 8.0.0
@angular-devkit/schematics 8.0.0
@angular/cdk 7.3.1
@angular/material 7.3.1
@angular/material-moment-adapter 7.3.1
@ngtools/webpack 8.0.0
@schematics/angular 8.0.0
@schematics/update 0.800.0
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
Rather than having to prefix html-loader! to every html import in your project, a better way to do this is to extend the webpack configuration and register the html extension to use the html loader.
I followed this tutorial to do that. Note you'll need to do this for both the build and the serve commands.
I am facing this issue when upgrading to the latest version of angular and webpack. I also tried to install [email protected] but still getting this error.
Hey guys, same error. None of above solution worked form.
I upgraded from angular 6 > angular 8
I am running into the same issue after upgrading from angular 7.2 to 8.0.6
rm -rf node_modules
rm -f package-lock.json
npm install
did not work for me, neither did npm install [email protected] nor yarn
rm -rf node_modules rm -f package-lock.json npm install
Try:
npm install acorn
rm -rf node_modules
rm -f package-lock.json
npm install
@wootwoot1234 That would uninstall acorn and never install it again since you are deleting node_modules after that .
I am stuck with this too.. I wonder how it worked well in Angular 6, but not on 7,8... :(
@wootwoot1234 That would uninstall acorn and never install it again since you are deleting node_modules after that .
I am stuck with this too.. I wonder how it worked well in Angular 6, but not on 7,8... :(
By default npm install acorn will add it to your package.json. Then npm install will reinstall it. It worked for me.
It did work. :( but gives a guilty feeling. I hope this issue is natively fixed.
my issue was that I probably updated too far.
I created a new angular project using Angluar-CLI version 8.0.6, copied the package.json, migrated all other angular files by hand and got it working.
Just ran into this problem after upgrading from Angular 7 to 8.1... This fixed the problem for me:
rm -rf node_modules
rm package-lock.json
npm install --save-exact [email protected]
npm install
acorn & webpack got updated. If you use webpack >= 4.35.3, this issue is fixed.
Per @sod's comment, currently angular-devkit/build-angular requires webpack 4.35.2.
Just ran into this problem after upgrading from Angular 7 to 8.1... This fixed the problem for me:
rm -rf node_modules rm package-lock.json npm install --save-exact [email protected] npm install
It worked for me, here is my version details:
Angular CLI: 8.1.2
Node: 10.16.0
OS: win32 x64
Angular: 8.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.801.2
@angular-devkit/build-angular 0.801.2
@angular-devkit/build-optimizer 0.801.2
@angular-devkit/build-webpack 0.801.2
@angular-devkit/core 8.1.2
@angular-devkit/schematics 8.1.2
@angular/cdk 8.1.1
@angular/flex-layout 8.0.0-beta.26
@angular/material 8.1.1
@ngtools/webpack 8.1.2
@schematics/angular 8.1.2
@schematics/update 0.801.2
rxjs 6.5.2
typescript 3.4.5
webpack 4.35.2
Just to let people know, I got it working with NPM doing the following :
npm i angular-devkit/[email protected]
rm package-lock.json
rm -rf node_modules
npm i
Doing that makes everything works afterward. If you look at the installed packages, you can see that acorn is now at the proper version :

Hope this help someone :)
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.