This is because you're compiling with AOT compilation (which is a good thing, but has some limitations).
In this case, its because AOT does not support lambda functions in provider setup. See the AOT documentation. To fix it, just replace your lambda with a named and exported function:
export function getToken() { localStorage.getItem('token'); }
and then reference that instead:
provideAuth({
tokenName: 'token',
tokenGetter: getToken
})
There are quite a few other gotchas with AOT compilation, many of which are listed here: https://medium.com/spektrakel-blog/angular-writing-aot-friendly-applications-7b64c8afbe3f
You can of course alternatively opt to compile without AOT by omitting the --aot
argument from your ng build
command. But that will result in a larger, slower application.