节点长路径模块名称失败teamcity构建

时间:2015-04-23 07:30:51

标签: node.js continuous-integration teamcity

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

这是日志:

    [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

这个问题有任何长期解决方案吗?

2 个答案:

答案 0 :(得分:0)

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

这取决于你的具体情况我将如何解决这个问题。这就是我在公司设置的方式:

开发设置

某些节点模块必须全局安装,因此每个开发人员都必须全局安装(例如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。请注意,bower必须全局和本地安装(如果您使用它)。

这意味着每个开发人员都必须对您使用过一次的node_modules进行全局安装。您可能希望选择每个node_module的特定版本,以便每个人都使用相同的版本。您可以安装如下全局模块:

  

~npm install grunt-cli karma bower -g

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

  

~npm install

这意味着本地模块不必是你的git repo的一部分,我发现这是很好的做法,因为它不是源代码。但它也解决了你的git不支持long node_modules路径的问题。

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

构建服务器

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

多个项目 如果您有多个项目使用相同的本地node_modules进行构建,那么您应该查看grunt-collections。您可以通过这种方式为node_modules创建一个中心位置,因此开发人员只需为所有项目安装一次。这里有一个非常好的帖子:

Centralise node_modules in project with subproject

希望这可以解决问题

答案 1 :(得分:0)

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

更新到npm v3后跟rm -rf node_modules ; npm -i为我工作。 npm issue 2697详细介绍了最大限度的"文件夹结构包含在npm v3中(2015-06-25发布)。

相关问题