Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Can not run on Local IIS with ASPNETCORE_ENVIRONMENT set to Development #883

Closed
martinfletcher opened this issue Apr 21, 2017 · 13 comments
Closed

Comments

@martinfletcher
Copy link

I have a new Angular app creates with the spa templates which I need to run on Local IIS on developer machines, with the ASPNETCORE_Environment variable set to Development.

With this set, i get the following error:

Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'

Is there any solution to this?

@ADefWebserver
Copy link

It works fine on my machine if I first "publish" the application (In Visual Studio 2017 select Build then Publish).

See: Publishing and Running ASP.NET Core Applications with IIS

...If you absolutely have to run with IIS, you can publish the application to a local folder first, then configure an IIS virtual directory or site and use that to run your site...

@martinfletcher
Copy link
Author

That is corect in that it still runs, but not in Development mode. It is is Production mode.

I need to set the ASPNETCORE_Environment variable to Development so that it runs correctly on dev server.

Any info would be great.

@SteveSandersonMS
Copy link
Member

@martinfletcher Have you got repro steps that work on a clean machine? i.e., how exactly did you set up IIS to serve your application? It sounds like the IIS process is running with the wrong working directory, or something like that, which means it doesn't see your node_modules directory.

@martinfletcher
Copy link
Author

@SteveSandersonMS Thanks, I had already done that, but still did not work.

I discovered (from the source code) that http binding is required for aspnet-webpack (hard coded localhost on http).

I take it this will now break if i have require https filters in place? Is there specific urls that i can exclude from this, or ideally a better way of not having to have http binding for my app?

@martinfletcher
Copy link
Author

Apologies, this is the correct issue, not #227

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Apr 21, 2017

Are you saying that adding an http binding fixes it? What part of the source code are you referring to?

If adding an http binding in your IIS config fixes it, I'm surprised by that, since the only thing that HMR is doing with this is telling a local instance of Webpack dev middleware to listen for requests on http://localhost:someport, which should be completely independent of IIS (it's a separate, standalone server).

@martinfletcher
Copy link
Author

Sorry, red herring..... I still had ASPNETCORE_ENVIRONMENT=Production

What I am trying to achieve is to deploy my web app to Local IIS so that it can be targeted by another app without having to un 2 instances of visual studio and reference localhost:xxxxx etc

Basically here is what I have to achieve this:

Web app created using dotnet new angular (Spa Templates)
Publish (Debug build) to Local IIS
App Pool (No Managed Code)
Site pointing to correct directory
Site has ASPNETCORE_ENVIRONMENT=Development set

I am getting the following error when ASPNETCORE_ENVIRONMENT=Development:

System.AggregateException: One or more errors occurred. (Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (C:\Windows\TEMP\tmp7FA2.tmp:83:19)
at webpack_require (C:\Windows\TEMP\tmp7FA2.tmp:20:30)
at createWebpackDevServer (C:\Windows\TEMP\tmp7FA2.tmp:62:26)
at C:\Windows\TEMP\tmp804F.tmp:113:19
at IncomingMessage. (C:\Windows\TEMP\tmp804F.tmp:132:38)
at emitNone (events.js:86:13)
Current directory is: S:\dev\pub\BackOffice.Presentation.Web) ---> System.Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (C:\Windows\TEMP\tmp7FA2.tmp:83:19)
at webpack_require (C:\Windows\TEMP\tmp7FA2.tmp:20:30)
at createWebpackDevServer (C:\Windows\TEMP\tmp7FA2.tmp:62:26)
at C:\Windows\TEMP\tmp804F.tmp:113:19
at IncomingMessage. (C:\Windows\TEMP\tmp804F.tmp:132:38)
at emitNone (events.js:86:13)
Current directory is: S:\dev\pub\BackOffice.Presentation.Web
at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.d__71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.<InvokeExportAsync>d__141.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__101.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options)
at BackOffice.Presentation.Web.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in S:\dev\BackOffice\src\BackOffice.Presentation.Web\Startup.cs:line 44
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
---> (Inner Exception #0) System.Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (C:\Windows\TEMP\tmp7FA2.tmp:83:19)
at webpack_require (C:\Windows\TEMP\tmp7FA2.tmp:20:30)
at createWebpackDevServer (C:\Windows\TEMP\tmp7FA2.tmp:62:26)
at C:\Windows\TEMP\tmp804F.tmp:113:19
at IncomingMessage. (C:\Windows\TEMP\tmp804F.tmp:132:38)
at emitNone (events.js:86:13)
Current directory is: S:\dev\pub\BackOffice.Presentation.Web
at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.d__71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.<InvokeExportAsync>d__141.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__10`1.MoveNext()<---

@patrickgomes1968
Copy link

patrickgomes1968 commented May 21, 2017

Noob-alert! :)
I have the identical issue and my ASPNETCORE_ENVIRONMENT = 'Development'.
My app was working just fine for a week until today. I git reset to discard all changes in working directory from when it last worked okay. To no avail.
No I don't see a node_modules folder in my MVC project, but I tried copying it from another project, along with the webpack file, but it didn't help. Do I need to generate it somehow? Please help.
repo here
Unhandled exception:
System.AggregateException: One or more errors occurred. (Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (C:\Users\Patrick\AppData\Local\Temp\tmp73CF.tmp:83:19) at __webpack_require__ (C:\Users\Patrick\AppData\Local\Temp\tmp73CF.tmp:20:30) at createWebpackDevServer (C:\Users\Patrick\AppData\Local\Temp\tmp73CF.tmp:62:26) at C:\Users\Patrick\AppData\Local\Temp\tmp74BA.tmp:113:19 at IncomingMessage.<anonymous> (C:\Users\Patrick\AppData\Local\Temp\tmp74BA.tmp:132:38) at emitNone (events.js:86:13) Current directory is: C:\Users\Patrick\Desktop\Tech Studies\ASP-Projects\vega) ---> System.Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (C:\Users\Patrick\AppData\Local\Temp\tmp73CF.tmp:83:19) at __webpack_require__ (C:\Users\Patrick\AppData\Local\Temp\tmp73CF.tmp:20:30) at createWebpackDevServer (C:\Users\Patrick\AppData\Local\Temp\tmp73CF.tmp:62:26) at C:\Users\Patrick\AppData\Local\Temp\tmp74BA.tmp:113:19 at IncomingMessage.<anonymous> (C:\Users\Patrick\AppData\Local\Temp\tmp74BA.tmp:132:38) at emitNone (events.js:86:13) Current directory is: C:\Users\Patrick\Desktop\Tech Studies\ASP-Projects\vega at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.<InvokeExportAsync>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.d__141.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.<InvokeExportWithPossibleRetryAsync>d__101.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options) at Vega.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\Users\Patrick\Desktop\Tech Studies\ASP-Projects\vega\Startup.cs:line 55 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Vega.Program.Main(String[] args) in C:\Users\Patrick\Desktop\Tech Studies\ASP-Projects\vega\Program.cs:line 15

@ADefWebserver
Copy link

patrickgomes1968 Can you re-install the templates (just run dotnet new --install Microsoft.AspNetCore.SpaTemplates::* again) and create a new project and see if that works?

@patrickgomes1968
Copy link

@ADefWebserver : Thanks. Re-installed them. Created a new proj. But still getting the same exception(s).
Would it have made a difference that I tried running my old project first after re-installing the templates?

@ADefWebserver
Copy link

@patrickgomes1968 : I do not think running your old project made a difference. The only other thing I can suggest is un-installing and re-installing Node.

@SteveSandersonMS
Copy link
Member

@patrickgomes1968 It sounds like your Node.js setup is pretty messed up. If I was in your situation, I'd purge every trace of Node (including node_modules directories anywhere - a common mistake is somehow getting a node_modules directory in your home folder, or hard drive root, which then interferes with NPM everywhere) and reinstall it. Disclaimer: back up your stuff; deleting things is your own choice :)

Both the @patrickgomes1968 and @martinfletcher reports appear to be due to problematic Node installations, which is outside the scope of this repo, so I'll close this. Hope that's OK!

@cahitbeyaz
Copy link

@patrickgomes1968 you can not run procution publish with environment variable indicating development for angular project

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants