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

执行npm run start-dev命令时遇报错,寻求技术帮助

Troubleshooting npm run start-dev Execution Issues

Hey there, let's work through why your npm run start-dev command is giving you trouble. From the output you shared, we can see the script is trying to run webpack in watch mode and nodemon side by side, but something's clearly off (you mentioned an error, even though the output cuts off at "Webpack is watching the files…"). Let's break down fixes step by step:

  • Fix Windows-specific command syntax
    The & operator you're using to run commands in parallel works on Mac/Linux, but Windows handles multi-command scripts differently—and since your project path is on a Windows drive (D:\Job\...), this is likely the main issue.

    • For sequential execution (run webpack first, then nodemon once it finishes), update your package.json script to use &&:
      "start-dev": "set NODE_ENV=development && webpack -w && set NODE_ENV=development && nodemon server.js"
      
    • If you need both tools to run at the same time, use the concurrently package—it’s built for cross-platform parallel execution. First install it:
      npm install --save-dev concurrently
      
      Then update your script:
      "start-dev": "concurrently \"set NODE_ENV=development && webpack -w\" \"set NODE_ENV=development && nodemon server.js\""
      
  • Ensure webpack and nodemon are installed locally
    Global package installations can clash with local project dependencies. Run this command to check if they’re listed in your devDependencies:

    npm list webpack nodemon
    

    If they’re missing, install them locally with:

    npm install --save-dev webpack nodemon
    
  • Test webpack and nodemon separately
    Sometimes one tool fails silently while the other starts up. Isolate each command to pinpoint the problem:

    1. Run just the webpack part first to check for config errors:
      set NODE_ENV=development && webpack -w
      
      If there’s an issue with your webpack.config.js, this will spit out detailed error messages to guide your fix.
    2. If webpack runs fine, test nodemon alone to check for server-side issues:
      set NODE_ENV=development && nodemon server.js
      
      Look for errors like missing modules, syntax mistakes in server.js, or port conflicts here.
  • Double-check your package.json formatting
    Since you mentioned a JSON file screenshot, make sure your scripts section is valid JSON (no trailing commas, all strings wrapped in double quotes). A properly formatted section should look like this:

    "scripts": {
      "start-dev": "your-updated-command-here",
      "build": "webpack --mode production"
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:29:36