microsoft / service-fabric

Service Fabric is a distributed systems platform for packaging, deploying, and managing stateless and stateful distributed applications and containers at large scale.
https://docs.microsoft.com/en-us/azure/service-fabric/
MIT License
3.02k stars 399 forks source link

Default Visual Studio 2017 Angular project template issues #157

Open YAJeff opened 6 years ago

YAJeff commented 6 years ago

Tried multiple times generating this from the project templates in Visual Studio.

  1. Visual Studio build waits indefinitely for NPM.cmd install to execute. Fixed this by Closing Visual Studio, deleting the npm-shrinkwrap.json file and running npm install from the project folder to fix.

  2. Deployment fails. Service fabric application type shows up, but nothing underneath it. Here's the error that caught my attention in the build process:

    ERROR in ./ClientApp/boot.browser.ts
    Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.browser.module.ngfactory' in 'C:\**************************************\ClientApp'
     @ ./ClientApp/boot.browser.ts 5:0-95
    Child
    Hash: 7025cb69320ab1d744e5
    Time: 10183ms
             Asset     Size  Chunks                    Chunk Names
    main-server.js  1.81 MB       0  [emitted]  [big]  main-server
    
    ERROR in ./ClientApp/boot.server.ts
    Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.server.module.ngfactory' in 'C:\************************************\ClientApp'
     @ ./ClientApp/boot.server.ts 8:0-94
    C:\************************************.csproj(52,5): error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.

    Fixed this by closing Visual Studio and running:

    ncu
    ncu -u
    npm install
  3. Deployment succeeds but app just starts crashing over and over again. Here's the error I get from the Service Fabric Explorer:

    Error: Cannot find module 'webpack-dev-middleware'

    Fixed this by closing Visual Studio and running:

    npm install webpack-dev-middleware --save-dev
  4. Everything starts and app appears to be healthy within Service Fabric Explorer. But visiting the root URL, I get this error:

    NodeInvocationException: Prerendering failed because of error: Error: Cannot find module "./../$$_gendir/ClientApp/app/app.server.module.ngfactory"
    at Object.<anonymous> (C:\*********************************\ClientApp\dist\main-server.js:15876:7)
    at __webpack_require__ (C:\*********************************\ClientApp\dist\main-server.js:20:30)
    at C:\*********************************\ClientApp\dist\main-server.js:66:18
    at Object.<anonymous> (C:\*********************************\ClientApp\dist\main-server.js:69:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    Current directory is: C:\*********************************
    Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+<InvokeExportAsync>d__7.MoveNext()

    Attempted to fix this by changing this (in the webpack.config.js file):

    const AotPlugin = require('@ngtools/webpack').AotPlugin;

    to this:

    const AotPlugin = require('@ngtools/webpack').AngularCompilerPlugin;

With no luck :( Please help. I don't think using the default Service Fabric Angular template should be this difficult.

vturecek commented 6 years ago

My only guess is that the application still isn't being packaged properly at build time. Looks like you got past some of the npm insanity to get a functioning binary package that doesn't crash on startup, but there's still some module that isn't being packaged? @dbreshears do you know anyone that understands this angular template?

dbreshears commented 6 years ago

Which version of Visual Studio 2017 do you have installed? I just tried the default scenario with both the new .NET Core 2.0 Angular service template as well as a the .NET Framework Stateless ASP.NET Core Angular service template, and they built and deployed fine on 6.2.

Do you also see this outside Service Fabric context via the general web templates?

Can you try 15.7.4 if you are not on that version? Maybe it is related to Node.js version which I have v8.11.1 installed.

YAJeff commented 6 years ago

I'm on Visual Studio 15.7.4 & v8.11.3

I did experience the fiasco with the release/unrelease/re-release of 6.2. Is it possible my templates are somehow corrupt?

ismasantana commented 6 years ago

+1