首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >节点长路径模块名称无法进行teamcity构建

节点长路径模块名称无法进行teamcity构建
EN

Stack Overflow用户
提问于 2015-04-23 15:30:51
回答 2查看 1.1K关注 0票数 2

我们正在尝试在我们的asp.net MVC项目中安装node,但是当我们签入代码时,它会导致team city中的构建失败。这是由于NPM使用的长模块路径名称这一众所周知的问题。

日志如下:

代码语言:javascript
复制
    [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

错误:

代码语言:javascript
复制
    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

这个问题有什么长期的解决方案吗?

EN

回答 2

Stack Overflow用户

发布于 2015-04-23 16:29:39

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

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

用于开发的设置

一些节点模块必须全局安装,因此每个开发人员都必须全局安装这些模块(例如grunt-cli、karma、bower )。可以/必须在本地安装的另一个node_modules可以添加到package.json文件中,如下所示:

代码语言:javascript
复制
      "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"
       }

你可以在http://browsenpm.org/package.json这里找到更多关于package.json的信息。请注意,必须在全局和本地安装bower (如果您正在使用它)。

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

~ npm安装grunt bower -g

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

~ npm安装

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

如果您的Node setup构建过程不再更改,则全局和本地安装的npm_modules将不再需要更改。如果您更改了工具,每个开发人员都必须重做npm安装。但对我来说,这还没有发生。

构建服务器

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

Multiple projects如果你有多个项目使用相同的本地node_modules进行构建,你应该看看grunt-collections。你可以通过这种方式为node_modules创建一个中心位置,这样开发人员只需为所有项目安装一次,这里有一篇关于这方面的很好的文章:

Centralise node_modules in project with subproject

希望这能把事情说清楚

票数 0
EN

Stack Overflow用户

发布于 2015-11-02 20:01:52

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

rm -rf node_modules ; npm -i之后更新到npm v3对我来说很有效。npm issue 2697提供了npm v3 (发布于2015-06-25)中包含的“maximally flat”文件夹结构的详细信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29816594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档