Reputation: 11
If I want to make ng serve, I get this error :
ERROR in TypeError: Cannot read property 'provide' of undefined at C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@angular\compiler-cli\src\ngtools_impl.js:150:14 at Array.reduce (native) at _collectRoutes (C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@angular\compiler-cli\src\ngtools_impl.js:149:22) at _extractLazyRoutesFromStaticModule (C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@angular\compiler-cli\src\ngtools_impl.js:113:8) at Object.listLazyRoutesOfModule (C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22) at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39) at AotPlugin._getLazyRoutesFromNgtools (C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@ngtools\webpack\src\plugin.js:207:44) at _donePromise.Promise.resolve.then.then.then.then.then (C:\Users\Samir\Documents\AngularProjects\test\angular_website\node_modules\@ngtools\webpack\src\plugin.js:443:24)
I also deleted all node_modules and installed the newest version of the cli, but this is not my code. Has someone a solution for this problem ?
Upvotes: 1
Views: 766
Reputation: 106
The issue is due to @Injectable(). Previous to Angular 11, @Injectable needs to be added for injecting services within a service.
In Angular 11 and future releases, @Injectable() needs to be added to all the defined services.
Upvotes: 0
Reputation: 276
In app.module.ts
, are you using any import like this:
import MyImport from 'myPath';
?
If yes, you need change your MyImport.ts
to be imported like this:
import { MyImport } from 'myPath';
Upvotes: 0
Reputation: 1826
This error is usually comming from the import statement of a service. You should try importing the service using the exact path of the service itself instead of using an index.ts file that exports the service.
Instead of
Using index.ts file with:
export * from './services/myservice.service';
and then in the module/component that provides that service you are writing the import to the index.ts file like that:
import {MyService} from './services';
Try this
Try to import the service using the relative path to the service itself:
import {myService} from './services/myservice.service';
Upvotes: 1