克隆Redux项目运行npm start报错,node_modules缺失及webpack-dev-server未找到
Hey there! Let's break down what's going on here and get your app up and running smoothly.
What's Causing the Error?
Looking at your error log, two key clues tell us exactly what's wrong:
sh: 1: webpack-dev-server: not foundnpm WARN Local package.json exists, but node_modules missing, did you mean to install?
This simply means your project's dependencies (including the webpack-dev-server tool needed to start the app) haven't been installed yet. The node_modules directory—where npm stores all downloaded packages—is missing, so npm can't locate the required tools to execute the start script.
Step-by-Step Solutions
First, install all project dependencies
Navigate to your project root directory and run this command:npm installThis will read your
package.jsonfile and download every required package into thenode_modulesfolder.If webpack-dev-server still isn't found after full dependency install
You can install it explicitly as a development dependency (this is the recommended approach to avoid global version conflicts):npm install webpack-dev-server --save-devAlternatively, install it globally if you need access to it across multiple projects:
npm install -g webpack-dev-serverTroubleshoot npm cache issues (if installation fails)
Sometimes a corrupted npm cache can block successful package installs. Clear the cache with:npm cache clean --forceThen run
npm installagain to retry the installation.
Once you've completed these steps, give npm start another try—your Redux app should fire up without that annoying error!
内容的提问来源于stack exchange,提问作者Deepak Mahakale

