如何解决React.js中的Webpack服务器错误

f45qwnt8  于 2023-06-23  发布在  Webpack
关注(0)|答案(1)|浏览(149)

我试图解决这个错误,但我不知道该怎么办。我已经intalled巴别塔扩展,然后开始得到这个错误,然后我删除了。但是,我现在也犯了错误,所以也许这与它无关。请帮我弄清楚。
【错误:】

Module not found: Error: Can't resolve 'D:#4 Web Development\\React-Concepts\\learn-react-
2\\node_modules\\webpack-dev-server\\client\\index.js?
protocol=ws%3A&hostname=0.0.0.0&port=3000&pathname=%2Fws&logging=none&overlay=%7B%22errors%22%3Atrue%2C%22wa
rnings%22%3Afalse%7D&reconnect=10&hot=true&live-reload=true' in 'D:#4 Web Development\\React-
Concepts\\learn-react-2'
ERROR in Module not found: Error: Can't resolve 'D:#4 Web Development\\React-Concepts\\learn-react-
2\\node_modules\\webpack-dev-server\\client\\index.js?
protocol=ws%3A&hostname=0.0.0.0&port=3000&pathname=%2Fws&logging=none&overlay=%7B%22errors%22%3Atrue%2C%22wa
rnings%22%3Afalse%7D&reconnect=10&hot=true&live-reload=true' in 'D:#4 Web Development\\React-
Concepts\\learn-react-2'

Package.json

{
  "name": "learn-react-2",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

index.js

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
gzjq41n4

gzjq41n41#

看起来你正在尝试使用一个你没有安装的模块,正如我从错误中看到的,我建议你试试这个:
npm install webpack-dev-server --save-dev
解决方案:从目录“#4 Web Development”中删除“#”

相关问题