“Please add a @NgModule annotation” Error on Angular2

后端 未结 4 557
慢半拍i
慢半拍i 2021-02-08 12:20

I have made a custom angular2(5.0.x) module that looks like this :

import { GuageService } from \'./services/guage.service\';
import { NgModule } from \'@angular         


        
4条回答
  •  [愿得一人]
    2021-02-08 13:15

    I had the same problem. With angular 5+ and angular cli 1.5 it says that your code is not compatible and also your library is scoped package. I have managed to fix it with adding

     export * from './your-path'
    

    In all my files (exporting everything from my library).

    As i understood its you import as 3 party library You can try to run the application with

     ng serve --preserve-symlinks
    

    also add flatModuleId in src/tsconfig.es5.json accordingly:

    "flatModuleId": "@scope/library-name"
    

    Link to github here

    There is issue on github for more information

提交回复
热议问题