Hi guys,
I'm using the new dotnet core 2.1 angular-cli template to create a new app which I'm trying to deploy to Service Fabric as a microservice. After the app is deployed to Service Fabric, I get the following error when I try to open it:
An unhandled exception occurred while processing the request.
AggregateException: One or more errors occurred.
System.Threading.Tasks.Task.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:83:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:214:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:252:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80: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:178: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 emitOne (events.js:116:13)
at process.emit (events.js:211:7)
at process._fatalException (bootstrap_node.js:374:26)
Error: EPERM: operation not permitted, mkdir 'C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm'
TypeError: Cannot read property 'get' of undefined
I know this might not be a template error and it might be related to Service Fabric, but 'C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm' seems pretty odd to me because Service Fabric starts the application as NETWORK SERVICE and not as SYSTEM. Throughout the process list I have no node process running as SYSTEM. I'm assuming it fails to start and it closes before I'm able to see it.
Is there a way to avoid running node as SYSTEM?
I do not know if this is related, but somehow my app (React/Redux) insists on running in Development mode when i run it through IIS. This in turn makes the app try to run the ReactDevelopmentServer which results in the same error as yours (EPERM: operation not permitted, mkdir 'C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm').
Adding an explicit environment to my web.config fixed the problem for me.
<aspNetCore processPath=".\XXX.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
How exactly are you deploying to Service Fabric?
My suspicion is that you're trying to deploy a non-published application. If that is what you're doing, then when the app tries to start up, it will try to perform an npm install which may be failing due to permissions issues.
If instead you were deploying a published application (e.g., the output from dotnet publish -c Release, or see Service Fabric docs/support for more info on publishing a .NET Core application to Service Fabric), then it wouldn't need to do the npm install at runtime because there's no instruction to do that in the published output.
Closing as I think that's what the issue is, but please let us know if not.
I am also facing the same issue. Is there any way to fix it
I have created the ASP.NET Core Project using Angular project template.
After publishing it to IIS If I run the application.
fail: Microsoft.AspNetCore.SpaServices[0]
Error: EPERM: operation not permitted, mkdir 'C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm'
@SteveSanderson from the log it looks like it fails when running npm start not npm install.
I had also few customers (I'm running shared hosting based on MSP Control - http://mspcontrol.org) which faced the same issue. Actually they never fixed this problem and used different solution.
@grzech1983 we didn't fix it either. The good thing is that we're not affected in production. This is a dev only thing. We changed a little the Startup.cs file and if we detect that an @angular/cli server is already running, we just forward requests to it.
@lucipacurar I've faced same issue with local cluster (SF SDK v 3.2.176) and VS 2017 template (v 15.8.2). Apparently the solution for me was to first start React template with ASPNETCORE_ENVIRONMENT variable set to Production, after that I've changed it back to Development and haven't seen it since then.
I banged my head against this issue for some time and finally figured out how to work around this issue. It turns out to be very simple:
Comment out the Startup.cs line //spa.UseAngularCliServer(npmScript: "start");
I'm not sure what the ramifications of this change are, but it does remedy the issue. I'm sure I'll figure out what that line does for me and have to come back and update this later. It is supposed to make automatic service updating work so that when you save your .ts, .js, .cshtml, and other files, you just need to refresh the browser and see the changes.
Looks like this template was created to be used in the context of an ASP.NET Core Web Application. In that context everything works just fine right out of the box.
Here's the full steps:
//spa.UseAngularCliServer(npmScript: "start");I just commented the line spa.UseAngularCliServer(npmScript: "start"); in Startup.cs and it fixed for me.
Thanks for posting this, it also resolved my problem as well with deployment to Service Fabric.
Most helpful comment
I do not know if this is related, but somehow my app (React/Redux) insists on running in Development mode when i run it through IIS. This in turn makes the app try to run the ReactDevelopmentServer which results in the same error as yours (EPERM: operation not permitted, mkdir 'C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm').
Adding an explicit environment to my web.config fixed the problem for me.