Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

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

Closed
lucipacurar opened this issue Apr 17, 2018 · 11 comments

Comments

@lucipacurar
Copy link

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?

@jovnas
Copy link

jovnas commented May 11, 2018

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>

@SteveSandersonMS
Copy link
Member

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.

@warisgeek
Copy link

I am also facing the same issue. Is there any way to fix it

@warisgeek
Copy link

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'

@lucipacurar
Copy link
Author

@SteveSanderson from the log it looks like it fails when running npm start not npm install.

@grzech1983
Copy link

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.

@lucipacurar
Copy link
Author

@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.

@TomaszSynak
Copy link

@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.

@SoundersFan
Copy link

SoundersFan commented Oct 4, 2018

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:

  1. Install VS 2017 and/or update as needed. Be that during install you select
    a. Workload: ASP.NET and web development (under Web & Cloud)
    b. Workload: .NET Core cross-platform development (under Other Toolsets)
    c. Individual components: IIS Express (under Cloud, database, and server)
    d. Individual components: Service Fabric Tools (under Cloud, database, and server)
  2. Install Service Fabric SDK
  3. Start VS 2017 as Administrator
  4. File->New Project
  5. Select Service Fabric Application
  6. Select Stateless ASP.Net Core
  7. Select Angular
  8. Check the HTTPS but I don’t think this is necessary but that’s what I do
  9. Comment out the Startup.cs line: //spa.UseAngularCliServer(npmScript: "start");
  10. Press F5

@amerbashoeb
Copy link

I just commented the line spa.UseAngularCliServer(npmScript: "start"); in Startup.cs and it fixed for me.

@AbacasX
Copy link

AbacasX commented Dec 8, 2018

Thanks for posting this, it also resolved my problem as well with deployment to Service Fabric.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants