节点长path模块名称失败teamcity构build

我们正在尝试在我们的asp.net MVC项目中安装节点,当我们检查我们的代码时,将会使团队城市中的构build失败。 这是由于众所周知的NPM使用的长模块path名称的问题。

这里是日志:

[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 

这个问题有没有长远的解决办法?

对评论的回应。 我在这里有更多的空间;)。

这取决于你的确切情况,我将如何解决这个问题。 这就是我在这里设置公司的方法:

设置开发

某些节点模块必须全局安装,因此每个开发人员必须全局安装(例如,grunt-cli,karma,bower)。 可以/必须在本地安装的其他node_modules可以添加到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" } 

有关package.json的更多信息,请点击这里http://browsenpm.org/package.json 。 请注意,凉亭必须安装在全球和本地(如果你正在使用它)。

这意味着每个开发都必须对您使用过的node_modules进行一次全局安装。 您可能需要select每个node_module的特定版本,以便每个人都使用相同的版本。 你可以像这样安装全局模块:

〜npm安装grunt-cli karma bower -g

将本地模块的package.json文件添加到项目的基本结构中,然后将其添加到git存储库。 每位将进行结帐的开发人员都将收到此文件。 他们将不得不安装本地模块,以便每个人都使用相同的工具:

〜npm安装

这意味着本地模块不必是你的git仓库的一部分,因为它不是源代码,所以我觉得这是很好的做法。 但是它也解决了你不支持长node_modulespath的问题。

如果您有一个构build过程,并且节点设置不再改变,那么全局和本地安装的npm_modules将不必更改。 如果你改变工具,每个开发将不得不重做npm安装。 但对我来说,这还没有发生。

构build服务器

您还必须在构build服务器上安装节点和这些全局模块,以便在构build过程中访问它们。 我所做的是创build一个.bat文件,该文件在包含“npm install”的构build过程中执行,以便在构build过程中parsingnode_modules。 这样,您也可以在构build过程中访问最新的工具。

多个项目如果您有多个项目使用相同的本地node_modules进行构build,则应该查看grunt-collections。 你可以用这种方式为node_modules创build一个中心位置,所以开发者只需要为所有的项目安装一次。这里有一个非常好的post:

使用子项目集中项目中的node_modules

希望这清除了事情

我也有这个错误,但在我的情况下,原因是使用过时的版本npm,v1.4.28。

更新到npm v3,然后是rm -rf node_modules ; npm -i rm -rf node_modules ; npm -i为我工作。 npm issue 2697详细介绍了npm v3中包含的“最大平面”文件夹结构(2015-06-25发布)。