Windows

使用 npm install 作為 MS-Windows 系統帳戶

  • August 20, 2014

我有一個在 Windows 上執行的節點應用程序,我希望能夠自動更新。當我npm install -d作為Administrator帳戶執行時 - 它工作正常,但是當我嘗試通過我的自動化軟體(執行為local system)執行它時,當我嘗試從私有 git 儲存庫安裝私有模組時出現錯誤:

   npm ERR! git clone git@bitbucket.org:team/repository.git fatal: Could not change back to 'C:/Windows/system32/config/systemprofile/AppData/Roaming/npm-cache/_git-remotes/git-bitbucket-org-team-repository-git-06356f5b': No such file or directory
   npm ERR! Error: Command failed: fatal: Could not change back to 'C:/Windows/system32/config/systemprofile/AppData/Roaming/npm-cache/_git-remotes/git-bitbucket-org-team-repository-git-06356f5b': No such file or directory
   npm ERR! 
   npm ERR!     at ChildProcess.exithandler (child_process.js:637:15)
   npm ERR!     at ChildProcess.EventEmitter.emit (events.js:98:17)
   npm ERR!     at maybeClose (child_process.js:735:16)
   npm ERR!     at Socket.<anonymous> (child_process.js:948:11)
   npm ERR!     at Socket.EventEmitter.emit (events.js:95:17)
   npm ERR!     at Pipe.close (net.js:451:12)
   npm ERR! If you need help, you may report this log at:
   npm ERR!     <http://github.com/isaacs/npm/issues>
   npm ERR! or email it to:
   npm ERR!     &lt;npm-@googlegroups.com&gt;

   npm ERR! System Windows_NT 6.1.7601
   npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-d"
   npm ERR! cwd D:\nodeapp
   npm ERR! node -v v0.10.8
   npm ERR! npm -v 1.2.23
   npm ERR! code 128

只需使用相同的系統執行 git clone 即可。有任何想法嗎?

更新:以下是_git_remotes目錄的權限:

> get-acl C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes |Format-list

Path   : Microsoft.PowerShell.Core\FileSystem::C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes
Owner  : BUILTIN\Administrators
Group  : NT AUTHORITY\SYSTEM
Access : NT AUTHORITY\SYSTEM Allow  FullControl
        BUILTIN\Administrators Allow  FullControl
Audit  :
Sddl   : O:BAG:SYD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)

不要將自動化軟體作為local system. 相反,創建一個新的專用服務帳戶(如果需要,管理員級別)。您也可以使該帳戶只能從該系統登錄,而不能遠端登錄。我會先嘗試以非管理員身份執行該軟體。

引用自:https://serverfault.com/questions/601004