GULP因VSTS错误而失败?

时间:2017-11-22 10:06:24

标签: node.js cordova npm gulp azure-devops

在VSTS Gulp操作上执行构建失败时出现错误:

" Gulp因错误而失败:C:\ NPM \ Modules \ gulp.cmd失败并返回代码:1"

我已经在VSTS上配置了我的项目,您可以在下面附带的屏幕截图中看到日志文件。

以下是错误日志:

 2017-11-22T09:30:58.3245047Z ##[debug]Evaluating condition for step: 'gulp '
    2017-11-22T09:30:58.3245047Z ##[debug]Evaluating: succeeded()
    2017-11-22T09:30:58.3245047Z ##[debug]Evaluating succeeded:
    2017-11-22T09:30:58.3245047Z ##[debug]=> (Boolean) True
    2017-11-22T09:30:58.3245047Z ##[debug]Expanded: True
    2017-11-22T09:30:58.3245047Z ##[debug]Result: True
    2017-11-22T09:30:58.3245047Z ##[section]Starting: gulp 
    2017-11-22T09:30:58.3255058Z ==============================================================================
    2017-11-22T09:30:58.3255058Z Task         : Gulp
    2017-11-22T09:30:58.3255058Z Description  : Node.js streaming task based build system
    2017-11-22T09:30:58.3255058Z Version      : 0.5.31
    2017-11-22T09:30:58.3255058Z Author       : Microsoft Corporation
    2017-11-22T09:30:58.3255058Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613721)
    2017-11-22T09:30:58.3255058Z ==============================================================================
    2017-11-22T09:30:58.3265054Z ##[debug]tf vc resolvePath "$\VisitReport_Br\Client Components\Main\Source\vr20-11.1\vr20-11.1\gulpfile.js" /loginType:OAuth /login:.,******** /noprompt
    2017-11-22T09:30:58.8355028Z ##[debug]d:\a\3\s\gulpfile.js
    2017-11-22T09:30:58.8535002Z ##[debug]tf vc resolvePath "$\VisitReport_Br\Client Components\Main\Source\vr20-11.1\vr20-11.1" /loginType:OAuth /login:.,******** /noprompt
    2017-11-22T09:30:59.3974984Z ##[debug]d:\a\3\s
    2017-11-22T09:31:00.2756125Z ##[debug]agent.workFolder=d:\a
    2017-11-22T09:31:00.2796114Z ##[debug]loading inputs and endpoints
    2017-11-22T09:31:00.2806186Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
    2017-11-22T09:31:00.2826125Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
    2017-11-22T09:31:00.2826125Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
    2017-11-22T09:31:00.2836118Z ##[debug]loading INPUT_CWD
    2017-11-22T09:31:00.2836118Z ##[debug]loading INPUT_ENABLECODECOVERAGE
    2017-11-22T09:31:00.2836118Z ##[debug]loading INPUT_GULPFILE
    2017-11-22T09:31:00.2846108Z ##[debug]loading INPUT_GULPJS
    2017-11-22T09:31:00.2846108Z ##[debug]loading INPUT_PUBLISHJUNITRESULTS
    2017-11-22T09:31:00.2846108Z ##[debug]loading INPUT_TESTFILES
    2017-11-22T09:31:00.2846108Z ##[debug]loading INPUT_TESTFRAMEWORK
    2017-11-22T09:31:00.2856108Z ##[debug]loading INPUT_TESTRESULTSFILES
    2017-11-22T09:31:00.2856108Z ##[debug]loaded 11
    2017-11-22T09:31:00.2856108Z ##[debug]check path : d:\a\_tasks\Gulp_b82cfbe4-34f9-40f5-889e-c8842ca9dd9d\0.5.31\task.json
    2017-11-22T09:31:00.2866123Z ##[debug]set resource file to: d:\a\_tasks\Gulp_b82cfbe4-34f9-40f5-889e-c8842ca9dd9d\0.5.31\task.json
    2017-11-22T09:31:00.2866123Z ##[debug]system.culture=en-US
    2017-11-22T09:31:00.2916104Z ##[debug]gulpFile=d:\a\3\s\gulpfile.js
    2017-11-22T09:31:00.2926117Z ##[debug]check path : d:\a\3\s\gulpfile.js
    2017-11-22T09:31:00.2976112Z ##[debug]gulp=C:\NPM\Modules\gulp.cmd
    2017-11-22T09:31:00.2986113Z ##[debug]enableCodeCoverage=false
    2017-11-22T09:31:00.2986113Z ##[debug]publishJUnitResults=false
    2017-11-22T09:31:00.2986113Z ##[debug]testResultsFiles=d:\a\3\s\**\TEST-*.xml
    2017-11-22T09:31:00.2996115Z ##[debug]cwd=d:\a\3\s
    2017-11-22T09:31:00.3006117Z ##[debug]path exists: d:\a\3\s
    2017-11-22T09:31:00.3006117Z ##[debug]check path : C:\NPM\Modules\gulp.cmd
    2017-11-22T09:31:00.3026103Z ##[debug]targets=null
    2017-11-22T09:31:00.3026103Z ##[debug]C:\NPM\Modules\gulp.cmd arg: []
    2017-11-22T09:31:00.3026103Z ##[debug]C:\NPM\Modules\gulp.cmd arg: --gulpfile
    2017-11-22T09:31:00.3036112Z ##[debug]C:\NPM\Modules\gulp.cmd pathArg: d:\a\3\s\gulpfile.js
    2017-11-22T09:31:00.3036112Z ##[debug]C:\NPM\Modules\gulp.cmd arg: d:\a\3\s\gulpfile.js
    2017-11-22T09:31:00.3036112Z ##[debug]arguments=null
    2017-11-22T09:31:00.3046108Z ##[debug]exec tool: C:\NPM\Modules\gulp.cmd
    2017-11-22T09:31:00.3046108Z ##[debug]Arguments:
    2017-11-22T09:31:00.3046108Z ##[debug]   --gulpfile
    2017-11-22T09:31:00.3046108Z ##[debug]   d:\a\3\s\gulpfile.js
    2017-11-22T09:31:00.3046108Z [command]C:\NPM\Modules\gulp.cmd --gulpfile d:\a\3\s\gulpfile.js
    2017-11-22T09:31:02.0185156Z [09:31:02] Local gulp not found in d:\a\3\s
    2017-11-22T09:31:02.0185156Z [09:31:02] Try running: npm install gulp
    2017-11-22T09:31:02.0305468Z ##[debug]rc:1
    2017-11-22T09:31:02.0305468Z ##[debug]success:false
    2017-11-22T09:31:02.0365138Z ##[debug]taskRunner fail
    2017-11-22T09:31:02.0375154Z ##[debug]task result: Failed
    2017-11-22T09:31:02.0475149Z ##[error]Gulp failed with error: C:\NPM\Modules\gulp.cmd failed with return code: 1
    2017-11-22T09:31:02.0475149Z ##[debug]Processed: ##vso[task.issue type=error;]Gulp failed with error: C:\NPM\Modules\gulp.cmd failed with return code: 1
    2017-11-22T09:31:02.0545148Z ##[debug]Processed: ##vso[task.complete result=Failed;]Gulp failed with error: C:\NPM\Modules\gulp.cmd failed with return code: 1
    2017-11-22T09:31:02.0555145Z ##[section]Finishing: gulp 

错误的屏幕截图是:

enter image description here

我的package.json文件的内容如下:

"devDependencies": {
      "karma": "^0.13.0",
      "karma-jasmine": "^0.3.6",
      "karma-chrome-launcher": "^0.2.0",
      "gulp": "^3.9.0",
      "jasmine-core": "^2.8.0",
      "karma-edge-launcher": "^0.4.2"
    }

1 个答案:

答案 0 :(得分:1)

原因是您没有在gulpfile.js的同一文件夹中安装Gulp。我认为package.json文件不在gulpfile.js文件的同一文件夹中。

由于gulpfile.js文件位于源目录中,您可以添加 npm task (工作文件夹:$(build.sourcesdirectory); npm命令:install;参数:{{ 1}})