TeamCity with npm – Error: ENOENT, stat ‘C:\Windows\system32\config\systemprofile\AppData\Roaming\npm’


I’m having serious problems getting the last pieces of my TeamCity configuration in place.

I have a powershell step that executes the following commands:

logging the following output:

I’ve seen that this is a known problem, but none of the solutions has worked for me so far.

My setup is the following: I have two virtual machines in Azure, build and agent. Both are connected to the same AD domain, domain, in which there is a user domain\teamcityuser, who is of “standard” class (i.e. not admin). This user runs both the build server (on the build instance) and the build agent (on the agent instance).

I’ve tried these things without success:

  • Creating the directory in the error message, making sure that domain\teamcityuser has full controll access rights to it.
  • Creating an npm directory under C:\Users\teamcityuser\AppData\Roaming
  • Creating a file C:\Windows\System32\config\SystemProfile\.npmrc with the contents prefix=C:\npm-global, as well as creating the latter folder
  • Running npm cache clean before running the build
  • Installing a global npm package through npm install -g npm

What more can I try to get this working?

And to avoid the XY problem, here’s my actual problem:

I have a .NET Web API project with CI setup through this TeamCity installation, via Octopus Deploy and to the hosting server. I also have a github repo with the code for a web SPA that will consume the API. The spa is built with grunt build, after which there’s a dist folder with everything I need to deploy.

I’d like to re-use as much as possible of the CI architecture to roll out the client too.


Given that path to executable contains SysWOW64, this is an x32 Powershell, therefore, it refers to x32 system profile path, which is located at C:\Windows\sysWOW64\config\systemprofile. So, you need to use that path as your base in order to implement any workarounds, say, create C:\Windows\sysWOW64\config\systemprofile\AppData\Roaming\npm folder, and not plain C:\Windows\system32\config\systemprofile\AppData\Roaming\npm.


TeamCity with npm – Error: ENOENT, stat ‘C:\Windows\system32\config\systemprofile\AppData\Roaming\npm’ by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply