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

Windows 10克隆仓库后执行npm脚本报错:Missing script: build

Fixing "npm ERR! missing script: build;" on Windows 10

Hey there! I see exactly what's going on here—this is a classic cross-platform shell syntax issue between Unix-like systems (where you were probably developing originally) and Windows.

The Root Cause

Your start script uses a Unix-style semicolon ; to chain two commands:

"start": "npm run build; webpack-dev-server --open --mode development"

On Windows, the default command prompt (CMD) doesn't recognize ; as a command separator. Instead, it treats the entire string build; as the name of the npm script you're trying to run. Since your package.json only has a script named build (not build;), npm throws that missing script error.

Quick Fixes

Here are a few ways to fix this, ordered by simplicity and best practice:

  1. Use && (Recommended for Sequential Execution)
    Replace the semicolon with &&—this tells Windows (and Unix systems) to run the second command only if the first one succeeds:

    "scripts": {
      // ... other scripts
      "start": "npm run build && webpack-dev-server --open --mode development"
    }
    
  2. Use & for Unconditional Execution
    If you want the second command to run even if the first fails, use a single & instead:

    "start": "npm run build & webpack-dev-server --open --mode development"
    
  3. Cross-Platform Script Runner (Most Robust)
    For full cross-platform compatibility (so you don't hit this issue again if switching between OSes), use npm-run-all:

    • First install it as a dev dependency:
      npm install --save-dev npm-run-all
      
    • Then update your scripts to use sequential execution:
      "scripts": {
        // ... other scripts
        "build": "webpack --mode development",
        "start:dev": "webpack-dev-server --open --mode development",
        "start": "run-s build start:dev"
      }
      

    run-s stands for "run sequential"—it will execute build first, then start:dev, no matter what OS you're on.

How to Test

After updating your package.json, save it and re-run:

npm start

This should now correctly run the build script followed by the dev server without errors.

内容的提问来源于stack exchange,提问作者Izzy Moppin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:18:06