inflearn logo
강의

講義

知識共有

Webゲームを作って学ぶReact

2-9. Webパックデブサーバーとのホットリロード

SocketClient is not a constructor 오류

854

ssj17441826

投稿した質問数 2

0

아랫분과 동일하게 Cannot get / 메세지가 계속 떠서 제로초님 공지글에 있는 4버전 깃허브 소스로 다 바꿨는데 SocketClient is not a constructor 에러 뜨면서 화면 로딩이 안됩니다.

"dependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/preset-env": "^7.12.1",
    "@babel/preset-react": "^7.12.1",
    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.0-rc.5",
    "babel-loader": "^8.1.0",
    "react-refresh": "^0.10.0",
    "webpack": "^5.3.2",
    "webpack-cli": "^4.1.0",
    "webpack-dev-server": "^4.0.0"
  }

const path = require("path");
const RefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");

module.exports = {
  name: "wordrelay-setting",
  mode: "development", // 실서비스: production
  devtool: "eval",
  resolve: {
    extensions: [".js", ".jsx"],
  },

  entry: {
    app: ["./client"],
  }, // 입력
  module: {
    rules: [
      {
        test: /\.jsx?/,
        loader: "babel-loader",
        options: {
          presets: [
            [
              "@babel/preset-env",
              {
                targets: {
                  browsers: ["> 5% in KR", "last 2 chrome versions"], // browserslist
                },
                debug: true,
              },
            ],
            "@babel/preset-react",
          ],
          plugins: ["react-refresh/babel"],
        },
      },
    ],
  },
  plugins: [new RefreshWebpackPlugin()],
  output: {
    path: path.join(__dirname, "dist"), 
    filename: "app.js",
    publicPath: "/dist",
  }, // 출력
  devServer: {
    devMiddleware: { publicPath: "/dist" },
    static: { directory: path.resolve(__dirname) },
    hot: true,
  },
};

react

回答 2

3

jy

저도 똑같은 오류해결하느라 찾아봤는데 아래와 같이 설정하는 방법으로도 오류해결을 할 수 있습니다. :)

 

plugins: [
    new RefreshWebpackPlugin({ overlay: false }),
],

0

jumpingboys3274

감사합니다. 덕분에 에러 해결되었습니다!!

0

zerocho

바꾸고 나서 npm i 하셨나요?

0

ssj17441826

네네 package.json 저장하고 npm i 도 완료했는데 화면이 로딩안됩니다ㅠ

pmmmwh/react-refresh-webpack-plugin, webpack-dev-server 등 설치파일들을 다시 npm i로 다운받고, 버전들은 깃허브에있는 버전으로 수정한뒤에 npm i 했습니다.

이후 npm run dev 했더니 터미널에는 에러가 안나는데 웹에 접속하면 아래처럼 에러가 납니다ㅠ

{
  "name""response-check",
  "version""1.0.0",
  "main""webpack.config.js",
  "scripts": {
    "dev""webpack serve --env development"
  },
  "repository": {
    "type""git",
    "url""git+https://github.com/Song-Sujin/react_study.git"
  },
  "author""Sujin",
  "license""MIT",
  "bugs": {
    "url""https://github.com/Song-Sujin/react_study/issues"
  },
  "homepage""https://github.com/Song-Sujin/react_study#readme",
  "dependencies": {
    "react""^17.0.1",
    "react-dom""^17.0.1"
  },
  "devDependencies": {
    "@babel/core""^7.12.3",
    "@babel/preset-env""^7.12.1",
    "@babel/preset-react""^7.12.1",
    "@pmmmwh/react-refresh-webpack-plugin""^0.4.3",
    "babel-loader""^8.1.0",
    "react-refresh""^0.9.0",
    "webpack""^5.3.2",
    "webpack-cli""^4.1.0",
    "webpack-dev-server""^4.0.0"
  }
}

 

const path = require("path"); // node에서 경로를 쉽게 조작할 수 있도록 해주는 것. path 가져오는 것
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
//process.env.NODE_ENV = "production";

module.exports = {
  name: "wordrelay-setting",
  mode: "development"// 실서비스: production
  devtool: "eval",
  resolve: {
    extensions: [".js"".jsx"],
  },

  entry: {
    app: ["./client"],
  }, // 입력
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        loader: "babel-loader",
        options: {
          presets: [
            [
              "@babel/preset-env",
              {
                targets: { browsers: ["last 2 chrome versions"] },
                debug: true,
              },
            ],
            "@babel/preset-react",
          ],
          plugins: ["react-refresh/babel"],
        },
        exclude: path.join(__dirname"node_modules"),
      },
    ],
  },
  plugins: [new ReactRefreshWebpackPlugin()],
  output: {
    path: path.join(__dirname"dist"),
    filename: "[name].js",
    publicPath: "/dist",
  },
  devServer: {
    devMiddleware: { publicPath: "/dist" },
    static: { directory: path.resolve(__dirname) },
    hot: true,
  },
};

1

zerocho

"@pmmmwh/react-refresh-webpack-plugin""^0.5.0-rc.6",

설치하세요.

npm run dev 실행 시 포트가 안뜨는 문제

0

211

2

timeouts.current를 useEffect 의 input값으로 넣었을때

0

89

2

렌더링 테스트 코드 (Hooks)

0

80

1

Cannot find package 'react-refesh' 이런 에러 뜨시는 분들 보세요.

0

154

1

해당 에러 뜨는 분들 보세요. "Uncaught TypeError: ReactDom.createRoot is not a function"

1

193

1

강사님 레포지토리에서 코드 복사 시 master 브랜치 말고 react18 브랜치꺼 복붙하세요ㅠㅠ

0

99

1

useMemo와 useCallback 사용 시기

0

208

2

onRightClickTd가 작동을 하지 않습니다.

0

228

1

action.type 불러오는 방식

0

222

2

onClickRedo 질문

0

172

1

const Try = require(./Try) 빨간줄

0

249

1

npx webpack 실행시

0

316

1

지뢰찾기 강좌에서 빈칸들 한번에 열기 파트에서 여쭤보고싶은부분이 있어서 글 올립니다.

0

236

1

강좌에서 다루지 않은 기능들은 어떻게 학습하면 좋을까요?

0

311

1

react devtool이 enable 않됩니다.

0

532

2

React 랜더링이 되지 않습니다.

0

414

2

비동기로 동작하는 setState에 대해서

0

332

1

npm run dev 할 때 에러발생

0

480

2

memo, PureComponenet, shouldComponentUpdate 관련 질문

0

207

1

devMiddleware의 필요성

0

354

1

리액트에서 화살표 함수를 사용해야하는 이유

0

937

2

path.join관련질문

0

283

2

2-9. 웹팩 데브 서버와 핫 리로딩 설치과정 시 에러

0

376

1

next.js 에서 이와 비슷한 예제를 돌리고있는데 react랑 달라서 질문 드립니

1

494

4