Docker support: SPA angular and .NETCore 2.0 #214

Closed
opened 2025-08-09 17:15:26 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @jfernandeze on 1/24/2018

I'm trying to add docker to template angular spa with .NET Core 2.0. I added docker support with Visual Studio 2017 and when I launch the application with docker-compose I have an error in

app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, });

This is the exception:

One or more errors occurred. (Failed to start Node process. To resolve this:.\n\n[1] Ensure that Node.js is installed and can be found in one of the PATH directories.\n Current PATH environment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n Make sure the Node executable is in one of those directories, or update your PATH.\n\n[2] See the InnerException for further details of the cause.)

The dockerfile has:

FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80

I've modified the Dockfile with:

FROM microsoft/aspnetcore:2.0 AS base
RUN curl -sL https://deb.nodesource.com/setup_8.x
RUN bash -
RUN apt-get -y update
RUN apt-get install -y build-essential nodejs
RUN ln -s /usr/bin/nodejs /usr/bin/node
WORKDIR /app
EXPOSE 80

When I launch Dockercompose I have the following error on the same line:

System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (Unexpected token {
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/app/node_modules/@ngtools/webpack/src/index.js:30:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10))
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options)
   at WebApplication12.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in c:\users\usuario\source\repos\WebApplication12\WebApplication12\Startup.cs:line 34

Inner Exception 1:
NodeInvocationException: Unexpected token {
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/app/node_modules/@ngtools/webpack/src/index.js:30:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Of course i'd like to use HMR with webpack and Docker

*Originally created by @jfernandeze on 1/24/2018* I'm trying to add docker to template angular spa with .NET Core 2.0. I added docker support with Visual Studio 2017 and when I launch the application with docker-compose I have an error in `app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, });` This is the exception: `One or more errors occurred. (Failed to start Node process. To resolve this:.\n\n[1] Ensure that Node.js is installed and can be found in one of the PATH directories.\n Current PATH environment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n Make sure the Node executable is in one of those directories, or update your PATH.\n\n[2] See the InnerException for further details of the cause.)` The dockerfile has: ``` FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 ``` I've modified the Dockfile with: ``` FROM microsoft/aspnetcore:2.0 AS base RUN curl -sL https://deb.nodesource.com/setup_8.x RUN bash - RUN apt-get -y update RUN apt-get install -y build-essential nodejs RUN ln -s /usr/bin/nodejs /usr/bin/node WORKDIR /app EXPOSE 80 ``` When I launch Dockercompose I have the following error on the same line: ``` System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (Unexpected token { SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/app/node_modules/@ngtools/webpack/src/index.js:30:10) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)) Source=<Cannot evaluate the exception source> StackTrace: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options) at WebApplication12.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in c:\users\usuario\source\repos\WebApplication12\WebApplication12\Startup.cs:line 34 Inner Exception 1: NodeInvocationException: Unexpected token { SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/app/node_modules/@ngtools/webpack/src/index.js:30:10) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) ``` Of course i'd like to use HMR with webpack and Docker
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#214
No description provided.