2015-04-23 75 views
2

我們正在嘗試在我們的asp.net MVC項目中安裝節點,當我們檢查我們的代碼時會怎麼樣會使團隊城市中的構建失敗。這是由於衆所周知的NPM使用的長模塊路徑名問題。節點長路徑模塊名稱失敗teamcity構建

這裏是日誌:

[08:07:46]Checking for changes 
[08:07:49]Publishing internal artifacts (5s) 
[08:07:54][Publishing internal artifacts] Sending build.start.properties.gz file 
[08:07:49]Clearing temporary directory: C:\TeamCity\buildagent3\temp\buildTmp 
[08:07:54]Clean build enabled: removing old files from C:\TeamCity\buildagent3\work\57c6a27fa330ee2f 
[08:07:54]Checkout directory: C:\TeamCity\buildagent3\work\57c6a27fa330ee2f 
[08:07:54]Updating sources: agent side checkout (15s) 
[08:07:54][Updating sources] Will perform clean checkout. Reason: Checkout directory is empty or doesn't exist 
[08:07:54][Updating sources] Cleaning C:\TeamCity\buildagent3\work\57c6a27fa330ee2f 
[08:07:54][Updating sources] VCS Root: git - tempsearch (15s) 
[08:07:54][VCS Root: git - tempsearch] revision: cf23c64dd32077edeb1b96a85d1be104bd127044 
[08:07:54][VCS Root: git - tempsearch] Cleaning C:\TeamCity\buildagent3\work\57c6a27fa330ee2f 
[08:07:54][VCS Root: git - tempsearch] The .git directory is missing in 'C:\TeamCity\buildagent3\work\57c6a27fa330ee2f'. Running 'git init'... 
[08:08:05][VCS Root: git - tempsearch] Checking out branch refs/heads/develop in git - tempsearch in C:\TeamCity\buildagent3\work\57c6a27fa330ee2f with revision cf23c64dd32077edeb1b96a85d1be104bd127044 
[08:08:10] 
[Updating sources] Failed to perform checkout on agent: '"C:\Program Files (x86)\Git\bin\git.exe" checkout -q -f develop' command failed. 
stderr: fatal: cannot create directory at 'node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion': No such file or directory 
[08:08:10]Publishing internal artifacts 
[08:08:10][Publishing internal artifacts] Sending build.finish.properties.gz file 
[08:08:10]Build failed to start. Artifacts will not be published for this build 
[08:08:10]Build finished 

錯誤:

Error while applying patch: Failed to perform checkout on agent: '"C:\Program Files (x86)\Git\bin\git.exe" checkout -q -f develop' command failed. 
stderr: fatal: cannot create directory at 'node_modules/grunt-contrib-jasmine/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion': No such file or director 

是否有任何長期解決這個問題呢?

+0

如果我正確理解這個,你將整個'node_modules'文件夾添加到你的git repo中?如果是這種情況,我寧願在你的git倉庫中保留一個'package.json'文件,這樣每個開發人員都可以自己安裝'node_modules'。我使用Jenkins作爲構建服務器,並且在Web構建中添加了'npm install' ,這樣這些依賴關係就可以在每次構建之前得到解決,這對團隊城市來說也是可能的嗎? –

+0

@DaanvanHulst這將如何解決問題?您的意思是每個開發人員只安裝他們需要的模塊或僅安裝模塊在開發者的環境中? – Xerxes

+0

添加了一個有用的答案 –

回答

0

對評論的迴應。我在這裏有更多的空間;)。

這取決於你的確切情況,我將如何解決這個問題。這是我如何在該公司在這裏設置的東西了:

設置開發

一些節點模塊必須在全球範圍內安裝的,所以每個開發商將不得不在全球範圍內安裝的(咕嚕-CLI,因果報應,例如涼亭)。可以/必須安裝其他node_modules本地您將添加到文件的package.json像:關於你的package.json可以在這裏找到http://browsenpm.org/package.json

 "devDependencies": { 
      "grunt": "~0.4.2", 
      "grunt-karma": "~0.7.3", 
      "karma-jasmine": "~0.2.0", 
      "karma-firefox-launcher": "~0.1", 
      "karma-chrome-launcher": "~0.1", 
      "karma-phantomjs-launcher": "~0.1", 
      "grunt-contrib-clean": "~0.4.1", 
      "grunt-contrib-copy": "~0.4.1", 
      "grunt-contrib-jshint": "~0.10.0", 
      "grunt-contrib-concat": "~0.3.0", 
      "grunt-contrib-watch": "~0.5.3", 
      "grunt-contrib-uglify": "~0.4.0", 
      "grunt-contrib-less": "~0.9.0" 
     } 

更多信息。請注意,涼亭必須在全球和本地安裝(如果您正在使用它)。

這意味着每個開發必須執行一次全局安裝的node_modules。您可能需要選擇每個node_module的特定版本,以便每個人都使用相同的版本。您可以安裝全球模塊是這樣的:

~ npm install grunt-cli karma bower -g

您與當地的模塊到你的項目的基本結構添加的package.json文件,您添加到Git倉庫。每位將進行結帳的開發人員都將收到此文件。他們將不得不做一個安裝本地模塊,使每個人都使用相同的工具:

~ npm install

這意味着本地模塊不必是你的混帳回購協議,我覺得這很好的做法的一部分因爲它不是源代碼。但它也解決了你不支持長node_modules路徑的問題。

如果您有一個不再更改節點設置的構建過程,則不必更改全局和本地安裝的npm_modules。如果你改變工具,每個開發將不得不重做npm安裝。但對我而言,這還沒有發生。

構建服務器

您也將讓您有在生成過程中對它們的訪問到構建服務器上安裝節點,這些全球性的模塊。我所做的是創建一個.bat文件,該文件在包含'npm install'的構建過程中執行,以便在構建期間解析node_modules。這樣您就可以在構建過程中訪問最新的工具。

多個項目 如果您有使用相同的本地node_modules爲構建多個項目,你應該看看咕嚕的集合。您可以創建這樣的node_modules一箇中心位置,所以開發者只需要一次安裝它們,所有的項目有一個非常好的一篇關於這個位置:

Centralise node_modules in project with subproject

希望這將清除的東西UPS

0

我也有這個錯誤,但在我的情況下,原因是使用過時的版本npm,v1.4.28。

更新到npm v3,然後rm -rf node_modules ; npm -i爲我工作。 npm issue 2697包含npm v3中包含的'最大平面'文件夾結構的細節(2015-06-25發佈)