With my Angular+Webpack+JHipster+yarn project I get the following error. Then I delete node_modules
and run 'npm install`, and it goes away. Then I do this and that and it comes back. How come? I'd like to not have to do that. The TranslateService listed in the error is one provided by a library, not one of my own, and is used in three generated components of my project that I did not write.
ERROR Error: No provider for TranslateService!
at injectionError (vendor.dll.js:1659)
at noProviderError (vendor.dll.js:1697)
at ReflectiveInjector_._throwOrNull (vendor.dll.js:3198)
at ReflectiveInjector_._getByKeyDefault (vendor.dll.js:3237)
at ReflectiveInjector_._getByKey (vendor.dll.js:3169)
at ReflectiveInjector_.get (vendor.dll.js:3038)
at GreatBigExampleApplicationAppModuleInjector.get (ng:///GreatBigExampleApplicationAppModule/module.ngfactory.js:515)
at GreatBigExampleApplicationAppModuleInjector.getInternal (ng:///GreatBigExampleApplicationAppModule/module.ngfactory.js:2452)
at GreatBigExampleApplicationAppModuleInjector.NgModuleInjector.get (vendor.dll.js:4005)
at resolveDep (vendor.dll.js:11467)
As documented on ngx-translate's github:
You have to import TranslateModule.forRoot() in the root NgModule of your application.
app.module.ts:
@NgModule({
imports: [
//...
TranslateModule.forRoot(),
],
//...
})
Or if you're using a SharedModule
:
If you use a SharedModule that you import in multiple other feature modules, you can export the TranslateModule to make sure you don't have to import it in every module
@NgModule({
exports: [
//...
TranslateModule,
],
//...
})
I'm not 100% sure what did it, but I deleted yarn.lock, corrected a node version discrepancy, renewed node_modules
and it seems to be fixed now. My pom.xml
had node 6.11.0 but I had been using 6.10.3 to install packages and run things.
UPDATE: Scratch that. The problem is back again. It started after changing a source file under node_modules/. It remained after reversing the change... after deleting yarn.lock... after deleting target/... after completely reinstalling all node modules... after checking out the master branch. Finally, after all that AND reinstalling all of the node modules, it works again.
I don't know what is going on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With