Azure DevOps gulp步骤失败,因为找不到本地模块

pobjuy32  于 2022-12-08  发布在  Gulp
关注(0)|答案(2)|浏览(188)

I have a Azure DevOps build step that runs gulp for an angularjs application. I set the Gulp file path to point to the GulpFile.js the referenced task should bundle the app and put the files into a zip file in the solution folder. This works fine when I run this locally in Visual Studio.
The error I am getting during the build is the following:
2019-07-08T15:54:56.5447810Z Task : Gulp 2019-07-08T15:54:56.5447868Z Description : Node.js streaming task based build system 2019-07-08T15:54:56.5447921Z Version : 0.141.2 2019-07-08T15:54:56.5447966Z Author : Microsoft Corporation 2019-07-08T15:54:56.5448064Z Help : More Information 2019-07-08T15:54:56.5448113Z ============================================================================== 2019-07-08T15:54:57.7184034Z [command]C:\Users\MYUSER\AppData\Roaming\npm\gulp.cmd Export --gulpfile C:\a_work\15\s\UI\Gulpfile.js 2019-07-08T15:54:58.6597682Z [[90m15:54:58[39m] Local modules not found in C:\a_work\15\s\UI 2019-07-08T15:54:58.6597830Z [[90m15:54:58[39m] Try running: npm install
Does this error occur because Node is missing the necessary modules to bundle the app. Can I make the bundle task call npm install for the app before continueing the task?

s4n0splo

s4n0splo1#

你可以添加一个任务只是在大口构建之前做npm install

steps:
- task: Npm@1
  displayName: 'npm install'
  inputs:
    command: install
    workingDir: '$(Build.SourcesDirectory)'
    verbose: false
lqfhib0f

lqfhib0f2#

Azure devops代理有自己的node.exe,安装在...\_work\_tool\node\(节点bin位置)中,例如D:\azure_devops_agent\_work\_tool\node\10.24.1\x64\node.exe
如果您的package.json(对于npm)或gulpfile.js(对于gulp)位于子文件夹中,则应提供其路径。
如果您使用的是传统管道并使用command line任务,则应在运行gulp命令之前按以下方式提供:

cd $(Build.SourcesDirectory)\subfolder
REM ..any gulp command...

截图:

相关问题