TeamCity 与 npm - 错误:ENOENT,stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'

2024-03-19

我在将 TeamCity 配置的最后一部分安装到位时遇到严重问题。

我有一个执行以下命令的 powershell 步骤:

& npm install
& grunt build

记录以下输出:

Build (Powershell) (1s)
[13:18:08]PowerShell Executable: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
[13:18:08]Working directory: C:\BuildAgent\work\6a434ee5d01fd0d9
[13:18:08]PowerShell arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, C:\BuildAgent\temp\buildTmp\powershell8407335260182621582.ps1]
[13:18:09]Error: ENOENT, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'
[13:18:09]
[13:18:09]grunt-cli: The grunt command line interface. (v0.1.13)
[13:18:09]Process exited with code 0

I've seen https://github.com/npm/npm/issues/1904这是一个known https://stackoverflow.com/questions/25093276/node-js-windows-error-enoent-stat-c-users-rt-appdata-roaming-npm问题,但都没有解决方案 https://github.com/npm/npm/wiki/Troubleshooting#error-enoent-stat-cusersuserappdataroamingnpm-on-windows-7到目前为止对我有用。

我的设置如下:我在 Azure 中有两个虚拟机,build and agent。两者都连接到同一个AD域,domain,其中有一个用户domain\teamcityuser,属于“标准”类别(即不是管理员)。该用户运行构建服务器(在build实例)和构建代理(在agent实例)。

我尝试过这些事情但没有成功:

  • 创建错误消息中的目录,确保domain\teamcityuser对其拥有完全控制访问权限。
  • 创建一个npm目录下C:\Users\teamcityuser\AppData\Roaming
  • 创建文件C:\Windows\System32\config\SystemProfile\.npmrc与内容prefix=C:\npm-global,以及创建后一个文件夹
  • Running npm cache clean在运行构建之前
  • 安装全局npm包通过npm install -g npm

我还可以尝试什么才能让它发挥作用?


并避免XY 问题 https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem,这是我的实际问题:

我有一个 .NET Web API 项目,通过此 TeamCity 安装、Octopus Deploy 和托管服务器进行 CI 设置。我还有一个 github 存储库,其中包含将使用 API 的 Web SPA 的代码。水疗中心是用grunt build,之后有一个dist包含我需要部署的所有内容的文件夹。

我也想尽可能多地重用 CI 架构来推出客户端。


鉴于可执行文件的路径包含SysWOW64,这是一个 x32 Powershell,因此,它指的是 x32 系统配置文件路径,该路径位于C:\Windows\sysWOW64\config\systemprofile。因此,您需要使用该路径作为基础才能实现任何解决方法,例如创建C:\Windows\sysWOW64\config\systemprofile\AppData\Roaming\npm文件夹,而不是普通的C:\Windows\system32\config\systemprofile\AppData\Roaming\npm.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TeamCity 与 npm - 错误:ENOENT,stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm' 的相关文章

随机推荐