I\'m getting this error after migrating to NgModule, the error doesn\'t help too much, any advice please?
Error: Error: Unexpected value \'undefined\' import
You have to remove line import { provide } from '@angular/core';
from app.module.ts
as provide
is deprecated now. You have to use provide
as below in providers :
providers: [
{
provide: APP_BASE_HREF,
useValue: '<%= APP_BASE %>'
},
FormsModule,
ReactiveFormsModule,
// disableDeprecatedForms(),
// provideForms(),
// HTTP_PROVIDERS, //DGF needed for ng2-translate
// TRANSLATE_PROVIDERS, //DGF ng2-translate (not required, but recommended to have 1 unique instance of your service)
{
provide : TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
},
{
provide : MissingTranslationHandler,
useClass: TranslationNotFoundHandler
},
AuthGuard,AppConfigService,AppConfig,
DateHelper
]
None of the above solutions worked for me, but simply stopping and running "ng serve" again.
The issue is that there is at least one import for which source file is missing.
For example I got the same error when I was using
import { AppRoutingModule } from './app-routing.module';
But the file './app-routing.module' was not there in given path.
I removed this import and error went away.
I had the same error, none of above tips didn't help.
In my case, it was caused by WebStorm, combined two imports into one.
import { ComponentOne, ComponentTwo } from '../component-dir';
I extracted this into two separate imports
import { ComponentOne } from '../component-dir/component-one.service';
import { ComponentTwo } from '../component-dir/component-two.model';
After this it works without error.
The Solutions above do not worked for me.
So I back the version of angular-cli of 1.6.4 for 1.4.4 and this solved my problem.
I do not know if this is the best solution, but for now, this worked for me
Make sure you should not import a module/component like this:
import { YOUR_COMPONENT } from './';
But it should be
import { YOUR_COMPONENT } from './YOUR_COMPONENT.ts';