Ngx-toastr: ASP.Net Core with Angular project fails to publish when ngx-toastr installed

Created on 24 Sep 2017  路  7Comments  路  Source: scttcper/ngx-toastr

Hello, I ran into an issue when running dotnet publish:

  1. Create a new angular application (single page application template) : dotnet new angular
  2. Installed and setup everything as instructed for ngx-toastr package.
  3. Awsome, my single page application builds and run in vs2017 and I can see the toastr alerts.
  4. When I try to publish: dotnet publish
    I have an error:
    ERROR in ./$$_gendir/~/ngx-toastr/index.ngfactory.ts
    Module parse failed: C:\Users\User\Documents\Visual Studio 2017\Projects\SinglePageApplication\$$_gendir\node_modules\ngx-toastrindex.ngfactory.ts Unexpected token (12:42)
    You may need an appropriate loader to handle this file type.
    | import * as i1 from 'ngx-toastr';
    | import * as i2 from '@angular/common';
    | export const ToastContainerModuleNgFactory:i0.NgModuleFactory = i0.鈺斺暋cmf(i1.ToastContainerModule,
    | ([] as any[]),(_l:any) => {
    | return i0.鈺斺暋mod([i0.鈺斺暋mpd(512,i0.ComponentFactoryResolver,i0.鈺斺暋CodegenComponentFactoryResolver,
    @ ./$$_gendir/ClientApp/app/app.module.browser.ngfactory.ts 10:0-81
    @ ./ClientApp/boot.browser.ts

I am using angular 4.2.5
Also checked with angular 4.4.3 - same issue.
Please let me know what's seems to be the problem.
Thank you.

angular-spa-template

Most helpful comment

Yes, thank you guys !
I had to remove include: /ClientApp/ from my webpack.config.js and it worked.

https://github.com/aspnet/JavaScriptServices/issues/1168

All 7 comments

Probably a server side rendering setup issue like angular-cli https://github.com/angular/angular-cli/issues/7200

As part of publishing, ensure the JS resources are freshly built in production mode:
Right-click and edit the .csproj file - this command causing the issue:
node node_modules/webpack/bin/webpack.js --env.prod

I've confirmed the issue. I'm not a webpack expert so only assuming I added this package correctly to the webpack.config.vendor.js file. I don't know what causes this. angular-cli uses webpack internally but somehow both are treating this library differently.

Yes, thank you guys !
I had to remove include: /ClientApp/ from my webpack.config.js and it worked.

https://github.com/aspnet/JavaScriptServices/issues/1168

Glad to hear. No problem.

I have this issue but with ngx-bootstrap and i do not have the line "incude: /ClientApp/" in my webpack.config.js file

Was this page helpful?
0 / 5 - 0 ratings