inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[리뉴얼] React로 NodeBird SNS 만들기

우분투에 노드 설치하기

npm run build 에러

6016

혜진

작성한 질문수 18

0

front 에서 npm run build 를 하려는데 다음과 같은 에러가 발생했어요

Cannot find module 'webpack' 부분을 보고 package.json 을 보니 webpack 이 안깔려있는 것을 확인하고 npm i webpack 으로 깐 뒤 커밋, 푸쉬하고 우분투 front 서버에서 git pull 까지 한 후 다시 npm run build 를 해도 저런에러가 뜨네요..

 

 

ubuntu@ip-172-31-14-223:~/NodeBird/front$ npm run build

> react-nodebird-front@1.0.0 build /home/ubuntu/NodeBird/front
> cross-env ANALYZE=true NODE_ENV=production next build

(node:20352) UnhandledPromiseRejectionWarning: Error: Cannot find module 'webpack'
Require stack:
- /home/ubuntu/NodeBird/front/node_modules/@next/react-refresh-utils/ReactRefreshWebpackPlugin.js
- /home/ubuntu/NodeBird/front/node_modules/next/dist/build/webpack-config.js
- /home/ubuntu/NodeBird/front/node_modules/next/dist/build/index.js
- /home/ubuntu/NodeBird/front/node_modules/next/dist/cli/next-build.js
- /home/ubuntu/NodeBird/front/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/home/ubuntu/NodeBird/front/node_modules/@next/react-refresh-utils/ReactRefreshWebpackPlugin.js:3:19)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:20352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20352) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

{
"name": "react-nodebird-front",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next -p 3060",
"build": "cross-env ANALYZE=true NODE_ENV=production next build",
"start": "cross-env NODE_ENV=production next start -p 3060"
},
"author": "JoHyeJin",
"license": "ISC",
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@next/bundle-analyzer": "^12.1.0",
"antd": "^4.18.3",
"axios": "^0.26.0",
"babel-plugin-styled-components": "^2.0.6",
"cross-env": "^7.0.3",
"faker": "^4.1.0",
"immer": "^9.0.12",
"moment": "^2.29.1",
"next": "^9.5.5",
"next-redux-wrapper": "^7.0.5",
"prop-types": "^15.8.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-redux": "^7.2.6",
"react-slick": "^0.28.1",
"redux": "^4.1.2",
"redux-devtools-extension": "^2.13.9",
"redux-saga": "^1.1.3",
"shortid": "^2.2.16",
"styled-components": "^5.3.3",
"swr": "^1.2.2"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^8.6.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"webpack": "^5.70.0"
}
}


 

 

react redux express nodejs Next.js

답변 6

0

혜진

아아 그렇네요.. aws 랑 git 을 다시 연결하고 npm i , npm run build 시도해도 똑같은데 어떡할까요 ㅜ

0

제로초(조현영)

서버에서 프론트 폴더의 package.json에 webpack이 있는지와 node_modules 폴더 안에 webpack이 있는지 확인하셔야 합니다.

아니면 로컬에서 .next 푸쉬해서 받아보셔도 됩니다.

0

혜진

아 이제껏 상위폴더에서 깃커밋을 안하고 front 에만 커밋을 했었네요 git reset --hard 도요.. 근데 아침에 답글을 보고 깃헙을 확인하니 왜 또 back 에서만 Feat: delete 되어있을까요 제가 건드리는 중에 뭘 잘못했는지 아예 연결도 끊겨버렸는데 그냥 새 레파지토리 생성하고, 서버연결도 처음부터 다시 하는게 나을까요? 서버도 여러 개가 되다보니 제가 헷갈려서 실수한것 같습니다ㅜ 이제껏 다른건 잘 헤쳐나갔는데 막판 배포부분이 멘붕이네요..

 

 

0

제로초(조현영)

백엔드 폴더는 수정한 게 없으니 Feat: delete고 프론트만 수정했으니 Feat: install webpack이겠죠.

git clone후 front 폴더 들어가서 npm i , npm run build가 순서입니다.

0

혜진

git reset --hard 한다음 다시 npm i 하고 npm run build 했는데 맞나요..?

 

0

제로초(조현영)

웹팩 넣은 버전이 깃 최신 커밋인게 맞나요? Feat: delete요

0

혜진

찾아보니 UnhandledPromiseRejectionWarning 에러가 프로미스, async 관련 에러로 catch block을 안쓰고 throw error를 사용해서 발생했다고 나와있는데 이게 어디 부분을 수정해야할 지, 웹팩모듈이 안보인다는 에러랑 무슨 연관이 있는지도 모르겠네요

또 비슷한 다른 분 질문에서 보니 로컬에서 빌드가 잘 되는 경우 .next 폴더까지 git에 올린 후 서버에서 받으면 (aws?)서버에서는 빌드하지 않아도 된다고 하셨는데, 저도 로컬 서버에서는 빌드가 잘 되고 있어서 그런데 .gitignore 에서 .next 를 지우고 푸쉬하면 되는건가요?

여기서 막혀서 진도를 못나가고있네요 흑

0

혜진

npm i 하고 git pull 을 하는건가요? npm i  를 해도 안되네요.. 자꾸 변경사항을 커밋을 하라는데 이미 webpack 설치해서 변경된 부분 커밋도 다 하고 푸쉬를 했는데 이해가 안가요ㅠ

 

 

 

 

0

제로초(조현영)

git pull 하고 npm i 해야하고요. 한번 깃풀하면 그 다음에 하지마세요. 꼬입니다. git reset --hard 한다음에 다시 npm i 하세요. 언핸들드프로미스는 그냥 경고입니다. 무시하세요. 에러가 아닙니다.

0

제로초(조현영)

서버서도 npm i 하세요

 

넥스트 버젼 질문

0

90

2

로그인시 401 Unauthorized 오류가 뜹니다

0

104

1

무한 스크롤 중 스크롤 튐 현상

0

191

1

특정 페이지 접근을 막고 싶을 때

0

116

2

createGlobalStyle의 위치와 영향범위

0

102

2

인라인 스타일 리렌더링 관련

0

97

2

vsc 에서 npm init 설치시 오류

0

157

2

nextjs 15버전 사용 가능할까요?

0

166

1

화면 새로고침 문의

0

129

1

RTK에서 draft, state 차이가 있나요?

0

160

2

Next 14 사용해도 될까요?

0

455

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

358

1

url 오류 질문있습니다

0

214

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

391

1

sudo certbot --nginx 에러

0

1293

2

Minified React error 콘솔에러 (hydrate)

0

477

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

255

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

337

1

npm run build 에러

0

525

1

front 서버 npm run build 중에 발생한 에러들

0

398

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

350

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

290

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

249

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

206

1