我试图创建一个运行自定义gulp命令的CI构建,但管道在任务Gulp@1上遇到了问题。我事先运行了一个NPM安装命令,该命令应包含gulp CLI依赖项。
以下是Azure管道返回的错误:
Starting: gulp
==============================================================================
Task : gulp
Description : Run the gulp Node.js streaming task-based build system
Version : 1.231.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/gulp
==============================================================================
##[error]Unhandled: Unable to locate executable file: 'gulp'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[error]Error: Unable to locate executable file: 'gulp'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
at Object._which [as which] (D:\agent_A\_work\_tasks\gulp_b82cfbe4-34f9-40f5-889e-c8842ca9dd9d\1.231.0\node_modules\azure-pipelines-task-lib\internal.js:323:23)
at Object.<anonymous> (D:\agent_A\_work\_tasks\gulp_b82cfbe4-34f9-40f5-889e-c8842ca9dd9d\1.231.0\gulptask.js:29:19)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Finishing: gulp
字符串
这是我在构建中运行的以下任务:
steps:
# Authenticate NuGet feeds to use this org's artifacts
- task: NuGetAuthenticate@0
displayName: 'Authenticate Nuget Feeds'
# Restore Nuget Tool Installer
- task: NuGetToolInstaller@1
displayName: NuGet Tool Installer
inputs:
versionSpec: '6.x'
# Restore Nuget Packages with Feed
- task: NuGetCommand@2
displayName: Restore Nuget Packages with Feed
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'select'
vstsFeed: 'feed'
- task: Npm@1
displayName: 'npm install'
inputs:
command: install
workingDir: '$(Build.SourcesDirectory)'
verbose: false
- task: Gulp@1
inputs:
workingDir: '$(Build.SourcesDirectory)'
gulpFile: 'gulpfile.js'
targets: 'proj:publish'
displayName: 'Build Proj'
型
注意:在本地构建项目确实有效。
2条答案
按热度按时间628mspwn1#
好吧,我找到了一个解决这个问题的方法。我只是添加了一个单独的任务来全局安装gulp CLI,它就解决了这个问题。
字符串
我认为我的项目是如何设置的以及如何安装软件包的问题。它在本地工作的原因是我已经在本地安装了Gulp CLI NPM软件包。
py49o6xq2#
虽然有一个安装
gulp-cli
的任务可以工作,但我建议将其添加到package.json中的devDependencies
中,这样npm install
就会自动安装它。字符串