Error: No provider for t

后端 未结 5 1107
Happy的楠姐
Happy的楠姐 2020-12-14 19:50

I am trying to compile my angular code to production mode via ng build --prod and its successful but in browser I get the error :

ERROR p {_         


        
相关标签:
5条回答
  • 2020-12-14 20:02

    I did not want to give up the optimization as the bundle size became about 8 times larger.

    luckily it turned out to be something stupid :) I had providers:[] section in one of my components When I removed it the error has disappeared.

    Hope this might be helpful for someone!

    0 讨论(0)
  • 2020-12-14 20:17

    Disable the terser plugin by editing the file:

    node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js

    and comment out:

    extraMinimizers.push(new TerserPlugin({
      sourceMap: scriptsSourceMap,
      parallel: true,
      cache: true,
      terserOptions,
    }));
    

    rebuild the app with ng build frontend --prod and you should be able to see in the console which service can't be injected.

    0 讨论(0)
  • 2020-12-14 20:19

    You are trying to use a service that is not listed in providers of your AppModule. Add the service to a providers list to make it work.

    0 讨论(0)
  • 2020-12-14 20:21

    Run the following command and first find which service dependency is missing. Fix it locally, Prod build will automatically works.

    ng serve --prod --optimization=false

    0 讨论(0)
  • 2020-12-14 20:21

    Your trying to access Service but not provides in your Module

    0 讨论(0)
提交回复
热议问题