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

Yarn 1.7执行yarn s启动Webpack失败,提示命令未找到

Fixing webpack: command not found & Node Version Mismatch Issues

Let’s tackle your problems one by one—they’re likely linked, so fixing the Node version first will resolve a lot of downstream headaches.

1. Resolve Node Version Mismatch

Your current Node version (10.2.1) doesn’t match the 6.9.1 specified in your package.json, which can cause dependency conflicts, broken installs, and unexpected command failures. Here’s how to fix it with nvm (Node Version Manager, the simplest way to manage multiple Node versions):

  • If you don’t have nvm installed, set it up first (follow the OS-specific setup steps for nvm—no external links needed).
  • Run nvm install 6.9.1 to download the exact Node version your project requires.
  • Switch to this version with nvm use 6.9.1.
  • Verify the change with node -v—it should output v6.9.1.

2. Fix npm s Triggering Search Instead of Starting Webpack

npm s is a shortcut for npm search, which is why you’re getting a search-related error. To run your project’s start script correctly:

  • Use the standard start command:
    npm start
    
  • If your package.json has a custom script named "s", run it explicitly with:
    npm run s
    

3. Fix yarn s webpack: command not found Error

This error typically means webpack isn’t installed locally, or your script isn’t pointing to the local webpack binary. Follow these steps to resolve it:

  • First, wipe corrupted dependencies by deleting your node_modules folder and lock file:
    rm -rf node_modules yarn.lock
    
  • Reinstall dependencies with the correct Node version:
    yarn install
    
  • Ensure webpack and webpack-cli are installed as dev dependencies (webpack 4+ requires webpack-cli to run):
    yarn add webpack webpack-cli --dev
    
  • Double-check your package.json scripts—make sure your "s" script targets the local webpack, like this (adjust flags to match your project needs):

    "scripts": {
    "s": "webpack --mode development"
    }

  • Run your script explicitly to avoid ambiguity:
    yarn run s
    

After completing these steps, your webpack build should run without the "command not found" error, and your Node version will align with the project’s requirements.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 07:34:42