JavaScriptServices icon indicating copy to clipboard operation
JavaScriptServices copied to clipboard

Docker support: SPA angular and .NETCore 2.0

Open jfernandeze opened this issue 8 years ago • 2 comments

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_6.x RUN bash - RUN apt-get -y update RUN apt-get install -y build-essential nodejs RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs WORKDIR /app EXPOSE 80

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

"One or more errors occurred. (Unexpected token {\nSyntaxError: Unexpected token {\n at exports.runInThisContext (vm.js:53:16)\n at Module._compile (module.js:373:25)\n at Object.Module._extensions..js (module.js:416:10)\n at Module.load (module.js:343:32)\n at Function.Module._load (module.js:300:12)\n at Module.require (module.js:353:17)\n at require (internal/module.js:12:17)\n at Object.<anonymous> (/app/node_modules/@ngtools/webpack/src/index.js:22:10)\n at Module._compile (module.js:409:26)\n at Object.Module._extensions..js (module.js:416:10))"

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

jfernandeze avatar Jan 16 '18 15:01 jfernandeze

It looks like you are close to making this work. The Unexpected token { error implies your version of Node is too old (i.e., it doesn't support some recent syntax). Make sure you install the latest version of Node into your container - at least version 8.x.

SteveSandersonMS avatar Jan 23 '18 16:01 SteveSandersonMS

@SteveSandersonMS It would be highly desirable if there was an SDK image that also included node so that npm install would work properly etc.

JohnGalt1717 avatar Aug 22 '18 20:08 JohnGalt1717