An AggregateException has occurred due to multiple errors arising. The main issue revolves around the failure to initiate the 'npm' application. To troubleshoot this problem and resolve it, further actions are

Experiencing frustration with Visual Studio on Mac when using Docker due to numerous errors. The project involves ASP.NET Core 2.1 with Angular 6 on a Docker image. The project builds successfully, but encounters issues when trying to run as detailed below:

An unhandled exception occurred while processing the request. AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this: 1 Ensure that 'npm' is installed and can be found in one of the PATH directories. Current PATH environment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Make sure the executable is in one of those directories, or update your PATH. 2 See the InnerException for further details of the cause.)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification) InvalidOperationException: Failed to start 'npm'. To resolve this: 1 Ensure that 'npm' is installed and can be found in one of the PATH directories. Current PATH environment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Make sure the executable is in one of those directories, or update your PATH. 2 See the InnerException for further details of the cause. Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo)

https://i.stack.imgur.com/Dcump.png

https://i.stack.imgur.com/Bgu7R.png

services.AddNodeServices(options =>
            {
                options.ProjectPath = "/Library/Frameworks/Mono.framework/Commands:/Applications/Visual Studio.app/Contents/Resources:/Applications/Visual Studio.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/usr/local/bin/";
            });

Here is the information from the Docker file:

FROM microsoft/dotnet:2.1-sdk AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY MeroRentalDev.sln ./
COPY WebApp/WebApp.csproj WebApp/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/WebApp
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApp.dll"]

Tried several solutions regarding the provided links, but none have resolved the issue.

System Aggregation Exception : Failed to start Node Process

Microsoft.AspNetCore.NodeServices: Failed to start node process

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

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

Answer №1

Resolved the issue successfully. The problem stemmed from node.js not being installed on the asp.net core 2.1 docker image.

To resolve this, Node.js needs to be installed in the Docker container.

# Setting up NodeJs
RUN apt-get update && \
    apt-get install -y wget && \
    apt-get install -y gnupg2 && \
    wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
    apt-get install -y build-essential nodejs
# End of setup

Before making any modifications, check the current Node version and adjust the value accordingly. In my case, I had version 8.11.3 so setup_8.x

Full Docker file below:

FROM microsoft/dotnet:2.1-sdk AS base

    # Setting up NodeJs
    RUN apt-get update && \
        apt-get install -y wget && \
        apt-get install -y gnupg2 && \
        wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
        apt-get install -y build-essential nodejs
    # End of setup
    WORKDIR /app
    EXPOSE 80

    FROM microsoft/dotnet:2.1-sdk AS build
    WORKDIR /src
    COPY MeroRentalDev.sln ./
    COPY WebApp/WebApp.csproj WebApp/
    RUN dotnet restore -nowarn:msb3202,nu1503
    COPY . .
    WORKDIR /src/WebApp
    RUN dotnet build -c Release -o /app

    FROM build AS publish
    RUN dotnet publish -c Release -o /app

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "WebApp.dll"]

Sources: GitHub Issue Stack Overflow Post

Answer №2

I have another potential culprit to share regarding the issue (though it is somewhat related to the existing solution) in order to assist those who are searching for this error message.


In addition to the current answer(s), this error could also occur if you mistakenly set the ASPNETCORE_ENVIRONMENT environment variable to 'Development' in non-Development environments.


For example, if you have a code snippet like the one below in your Startup.cs, and you have purposely not installed npm in that particular environment, you may encounter the mentioned error when your Dotnet application attempts to execute npm start.

if (env.IsDevelopment())
{
    spa.UseAngularCliServer(npmScript: "start");
}

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The struggle between Node.js 404 errors and Angular's URL refresh issue

I am currently developing a Node.js and AngularJS application. I encountered an issue where a page loads successfully when the URL is entered, but then I added a script to redirect to a 404 error page. Now, only one of the criteria works at a time - either ...

A guide on setting up ExpressJS Error Handling to display custom error messages based on the corresponding HTTP Status codes

I am struggling to figure out how to implement this task. You need to create an error on the /error path and pass it to the next function. Make sure to use appropriate error status codes for displaying different types of error messages. I attempted using ...

Issue with dependencies resolution in Nest framework

While delving into NestJS dependencies, I encountered an issue. As a beginner in learning Nest, I am still trying to grasp the correct way to structure everything. The problem lies in Nest's inability to resolve dependencies of the ChatGateway. It&a ...

Calling functions on bit objects is prohibited

I'm currently working on a project that involves checking for intersections between two geographical objects and removing the overlapping parts. The code snippet below seems to be causing an error: Cannot call methods on bit. I'm using the ms ...

Morgan logging fails to exclude logging of keep-alive requests

I have a node.js express application running on AWS behind an Elastic Load Balancer, with 'morgan' as the logging mechanism. The ELB sends periodic keep-alive requests to a 1-character text file (keep-alive.txt). To prevent these requests from ...

Step-by-step guide to restarting an MQTT subscriber using Node.js

Working on a Node Js and MQTT Project In this project, a device initially subscribes to a topic or list of topics and starts receiving messages published for those specific topic(s). An admin from the dashboard then assigns that device another new topic. ...

What could be causing the errorHandler middleware to be triggered twice in an express application?

const express = require('express') const app = express(); function middleWear1(req, res, next) { throw Error() } function errorHandler(err, req, res, next) { console.log("error handled"); res.end("error occured at ser ...

Can WebSocket messages be encoded?

Is there a way to encrypt or obscure the data I transmit via websockets? For example, the message looks like this: var encryptedMsg = { type: "message", data: { message: "Hello world!" } } I require the ability to send this message in ...

Is there a possible workaround for the restriction on temporary downloads by Heroku?

When my app starts, I aim to download images from MongoDB for faster performance and local access within the application. However, I encounter crashes on Heroku. How can I address this issue? Here is the code snippet I am attempting to implement: dir = " ...

When utilizing the fetch API to upload a file, the req.body is found to be empty and req.file is undefined

When using express and multer on the server, the code structure is as follows: const uploader = multer({ storage: multer.diskStorage({ destination: (_req, _file, cb) => cb(null, './uploads/'), filename: (_req, file, cb) => { ...

Encountering a TypeError in Laravel VueJS testing: Unable to locate _vm._ssrEscape function

I have been trying to set up Mocha tests for Laravel 7 Vue Components by combining different tutorials. Initially, I was able to run a basic test successfully: expect(0).toBe(0); However, when attempting to mount a component, I encountered the following ...

Creating unique message formats for communication between a python client and a socket.io node.js server

Currently, I am attempting to establish communication between a Python client and a Node.js server using Socket.io 0.7. My goal is to send a custom event from the client to the server. To achieve this, I have been referencing the Socket.io documentation o ...

Error message "invalid function call this.job.execute" when using Node.js node-schedule npm package

Having just started with nodejs, I created a nodejs program and set it to run every minute using the node-schedule library. However, after running for some time and producing several logs in the console, I encountered an error stating that this.job.execute ...

How can you set up an Express JS application based on different environments such as development, staging, and production?

Embarking on my journey into expressjs app development, I find myself in the midst of configuring my application according to different environments. I stumbled upon tools like 'node-env-file' and 'cross-env', but their usage seems a bi ...

Error: 'require' function is not recognized in the latest JavaScript file

I am interested in using anime.js. To install this library, I need to follow these steps: $ npm install animejs --save const anime = require('animejs'); The code should be written in a js file named "anime.js" Here is the code for "anime.js": ...

Using Nginx and Express to deliver static content directly from a Docker container

My setup involves an Express API and an Nginx running in a Docker Container. The goal is to have Nginx reverse proxy regular requests to the API, while also serving static files like images directly. However, I'm struggling to determine the correct U ...

npm ERROR: Unable to install the package named "<packageName>" because it conflicts with an existing package of the same name

Currently, I am attempting to incorporate the jsonfile package into my project. However, I am encountering a couple of errors: An issue arises when attempting to install a package with the same name as another package within the same directory. (Despite ...

The code encountered an error because it tried to access the property 'isServer' from an undefined value

I encountered an error when attempting to run yarn install in my project folder. yarn install v1.22.15 [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... error An unexpected error occurred: "https://registry.y ...

Issue: Failure to generate models using Loopback's discoverAndBuildModels

I'm currently working on implementing Loopback for table discovery and creation. I have followed the example provided on their documentation page, which can be found at the following link: After executing the code, I am able to see the output of the ...

The created date value is missing in the returned object for the voice call

I am currently developing an express/nodejs application that triggers a DB event and then makes multiple calls to notify about a special occurrence. These calls are made using Twilio for NodeJS. However, after making the call, the returned object contains ...