Я перепробовал все решения в стеке с похожим вопросом:

Ошибка возникает в этой точке:
return this.http.post<any>(`${config.apiUrl}/users/authenticate`, { username, password })
webpack.config.js
new webpack.DefinePlugin({
// global app config object
config: JSON.stringify({
apiUrl: 'http://localhost:4000'
})
})
typings.d.ts
declare var config: any;
authentication.service.ts
login(username: string, password: string) {
debugger;
return this.http.post<any>(`${config.apiUrl}/users/authenticate`, { username, password })
.pipe(map(user => {
// login successful if there's a jwt token in the response
if (user && user.token) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('currentUser', JSON.stringify(user));
this.currentUserSubject.next(user);
}
return user;
}));
}