2
votes

Hi guys i've made an angular 7 app with visual studio 2017. So i got AWS machine on windows 10 with IIS.

When i loaded the app, i got this error:

AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

So the image with the iis error return:

enter image description here

Complete text error:

   An unhandled exception occurred while processing the request.

AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
if (npm.config.get('json')) {
^

TypeError: Cannot read property 'get' of undefined
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at process.emit (events.js:189:13)
at process._fatalException (internal/bootstrap/node.js:496:27)
Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:229:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205

if (npm.config.get('json')) {

^


TypeError: Cannot read property 'get' of undefined

at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)

at process.emit (events.js:189:13)

at process._fatalException (internal/bootstrap/node.js:496:27)

))
System.Threading.Tasks.Task<TResult>.GetResultCore(bool waitCompletionNotification)

InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
if (npm.config.get('json')) {
^

TypeError: Cannot read property 'get' of undefined
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at process.emit (events.js:189:13)
at process._fatalException (internal/bootstrap/node.js:496:27)
Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:229:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205

if (npm.config.get('json')) {

^


TypeError: Cannot read property 'get' of undefined

at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)

at process.emit (events.js:189:13)

at process._fatalException (internal/bootstrap/node.js:496:27)

Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(string sourcePath, string npmScriptName, ILogger logger)

Stack Query Cookies Headers
AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm' 
 TypeError: Cannot read property 'get' of undefined 
 at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7 at Array.forEach (<anonymous>) at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13 at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25) at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
 if (npm.config.get('json')) {
 ^

 TypeError: Cannot read property 'get' of undefined
 at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
 at process.emit (events.js:189:13)
 at process._fatalException (internal/bootstrap/node.js:496:27)
 Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm' 
 TypeError: Cannot read property 'get' of undefined 
 at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7 at Array.forEach (<anonymous>) at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13 at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25) at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20) at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:229:20) C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205

 if (npm.config.get('json')) {

 ^


 TypeError: Cannot read property 'get' of undefined

 at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)

 at process.emit (events.js:189:13)

 at process._fatalException (internal/bootstrap/node.js:496:27)

 ))
System.Threading.Tasks.Task<TResult>.GetResultCore(bool waitCompletionNotification)
Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.WithTimeout<T>(Task<T> task, TimeSpan timeoutDelay, string message)
Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task<Uri> baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)
Microsoft.AspNetCore.Builder.SpaProxyingExtensions+<>c__DisplayClass2_0+<<UseProxyToSpaDevelopmentServer>b__0>d.MoveNext()
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Show raw exception details
InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm' 
 TypeError: Cannot read property 'get' of undefined 
 at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7 at Array.forEach (<anonymous>) at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13 at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25) at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
 if (npm.config.get('json')) {
 ^

 TypeError: Cannot read property 'get' of undefined
 at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
 at process.emit (events.js:189:13)
 at process._fatalException (internal/bootstrap/node.js:496:27)
 Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm' 
 TypeError: Cannot read property 'get' of undefined 
 at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7 at Array.forEach (<anonymous>) at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13 at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25) at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20) at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:229:20) C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205

 if (npm.config.get('json')) {

 ^


 TypeError: Cannot read property 'get' of undefined

 at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)

 at process.emit (events.js:189:13)

 at process._fatalException (internal/bootstrap/node.js:496:27)

Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(string sourcePath, string npmScriptName, ILogger logger)

Show raw exception details
System.InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at process.emit (events.js:189:13)
    at process._fatalException (internal/bootstrap/node.js:496:27)
Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

TypeError: Cannot read property 'get' of undefined

    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
    at Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:229:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205

  if (npm.config.get('json')) {

                 ^


TypeError: Cannot read property 'get' of undefined

    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)

    at process.emit (events.js:189:13)

    at process._fatalException (internal/bootstrap/node.js:496:27)

 ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath, String npmScriptName, ILogger logger)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath, String npmScriptName, ILogger logger)

Here Startup.cs

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

        // In production, the Angular files will be served from this directory
        services.AddSpaStaticFiles(configuration =>
        {
            configuration.RootPath = "ClientApp/dist";
        });
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseSpaStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller}/{action=Index}/{id?}");
        });

        app.UseSpa(spa =>
        {
            // To learn more about options for serving an Angular SPA from ASP.NET Core,
            // see https://go.microsoft.com/fwlink/?linkid=864501

            spa.Options.SourcePath = "ClientApp";

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

I've installed lates nodejs version on server. Where i'm wrong ?

Thanks

5
Can you show me th Backend code that serve angular app ?Tony Ngo
@TonyNgo What code you want see ? The backend it's big.Mr. Developer
What are you using for BE ? ASP.Net Core ? Node JS ?Tony Ngo
Ah sorry, you're right...the backend it's C# .net core 2.1Mr. Developer
Then upload the startup.cs for me I want to see itTony Ngo

5 Answers

4
votes

Try setting your environment to Production. I think it has something to do with trying to do a NPM start

<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
1
votes

Got a similar error but solved it by running the Application Pool Identity as LocalSystem instead of IIS AppPool\.... This enabled me to keep ASPNETCORE_ENVIRONMENT as Development and thereby debug the code on an actual IIS.

My error:

An unhandled exception occurred while processing the request. AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the create-react-app server was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

)) System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)

InvalidOperationException: The NPM script 'start' exited without indicating that the create-react-app server was listening for requests. The error output was: Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

Error: EPERM: operation not permitted, mkdir 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer.ReactDevelopmentServerMiddleware.StartCreateReactAppServerAsync(string sourcePath, string npmScriptName, ILogger logger)

0
votes

Did following steps for me its is working without running NPM start on server.

  • Go to web.config
  • open and change the ASPNETCORE_ENVIRONMENT from Development to Production.
  • Push your changes , this will work.
0
votes

I had this problem with Angular project template for VS 2019. I tried to refresh nodejs, set environment to "Production", comment spa.UseAngularCliServer(npmScript: "start"); in Startup.cs - app was hanging on "Loading...". Nothing helped.

What helped is creating "npm" folder in C:\Windows\System32\config\systemprofile\AppData\Roaming and assigning read permission for the folder to IIS_USR group.

0
votes

I solved this problem by changing the environment variable in web.config file. For Production environment you must change value of the variable "environmentVariable" in the file "web.config" in the project to be "Production". You can change it also in the publish profiles by adding the EnvironmentName Property {filename_environment}.pubxml:

<PropertyGroup>
 ...
 <EnvironmentName>Production</EnvironmentName>
</PropertyGroup>