You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps Pipeline脚本报错:Bash退出代码‘127’,YAML脚本失效

Fixing "Bash exited with code '127'" in Azure DevOps Pipeline

Hey there, let's break down why you're hitting that error and how to fix it quickly!

What's causing the error?

Exit code 127 in Bash almost always means the shell can't find the command you're trying to run. In your pipeline, you've got start in the script step—but on Ubuntu (your chosen VM image), start isn't a built-in system command. You're trying to execute the start script defined in your package.json, but you haven't used the correct syntax to tell npm to run it.

The Simple Fix

Update your script step to use npm run start instead of just start. Here's the corrected YAML configuration:

trigger:
  - master
pool:
  vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'
- script: |
    npm run start
  displayName: 'npm install and build'

Why This Works

When you define custom scripts in package.json, npm acts as the manager for these scripts. To execute one, you need to use the npm run <script-name> command—this tells npm to look up the script in your package.json and run its associated commands. Just typing start directly makes Bash search for a system-level command with that name, which doesn't exist on Ubuntu, hence the 127 error.

Bonus: Add Dependency Installation (If Needed)

If your start script relies on project dependencies that aren't pre-installed in the pipeline, you should add an npm install step first to ensure all packages are set up:

- script: |
    npm install
    npm run start
  displayName: 'npm install and build'

内容的提问来源于stack exchange,提问作者MD. Ashfaqur Rahman Tahashin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:37:13