해결된 질문
작성
·
4.9K
0
front 서버에서 npm run build 로 next 빌드를 할때 아래와 같은 에러가 발생합니다
/////////////////////////////////////////////////////////////
root@ip-172-31-16-162:/home/ubuntu/testAWS/front# npm run build
> react-nodebird-front@1.0.0 build /home/ubuntu/testAWS/front
> cross-env ANALYZE=true next build
Creating an optimized production build ...
Webpack Bundle Analyzer saved report to /home/ubuntu/testAWS/front/.next/analyze/server.html
Failed to compile.
./node_modules/@ant-design/icons/lib/dist.js 5:6
Module parse failed: 'import' and 'export' may only appear at the top level (5:6)
You may need an appropriate loader to handle this file type.
| // 加载script标签会阻塞js执行,antd部分组件(如表格)无法在一轮循环内完成完整的渲染,故延时
| setTimeout(function(){
> import(/* webpackChunkName: "antd-icons" */'!!./dist.js').then(function(allIcons) {
| AutoReloadIcon.load(allIcons);
| });
> Build error occurred
Error: > Build failed because of webpack errors
at Object.build [as default] (/home/ubuntu/testAWS/front/node_modules/next/dist/build/index.js:192:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-nodebird-front@1.0.0 build: `cross-env ANALYZE=true next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-nodebird-front@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-04-28T22_17_04_628Z-debug.log
///////////////////////////////////////////////////
next.config.js 를 삭제하여 기본값으로 next 빌드를 할때는 문제없이 빌드가 되는데 왜 next.config.js로 웹팩 옵션을 추가할때는 왜 안되는지 모르겠습니다 ..ㅠ.ㅠ
답변 7
1
1
2020. 04. 29. 14:02
지금 https://github.com/webpack/webpack/issues/8656
이 버그에 걸리신 것 같습니다. 웹팩 버전 알려주세요.
0
0
0
2020. 04. 29. 17:23
아... 제가 습관적으로 npm audit 를 해서 버전업이 되서 그런것 같습니다 ..^^;;;;
선생님 코드에서 몇가지 수정한것만 붙여넣으니 빌드가 잘 됩니다
답변 감사합니다!
0
2020. 04. 29. 17:06
강좌랑 버전을 다르게 하고 계시죠? antd3버전과 next8버전이 아닌 것 같습니다. 이 부분은 저도 버전을 업해서 다시 테스트해보야합니다.
0
2020. 04. 29. 15:30
답변감사합니다 제로초 선생님.
확인해보니 4.41로 되어있어서, 링크처럼 package.json에서 4.28로 설치하고 package-lock.json 을 확인해보니 4.29로 웹팩이 설치되었는데
여전히 같은 에러가 발생합니다..ㅠ.ㅠ
////////////////////////////////////////
root@ip-172-31-16-162:/home/ubuntu/testAWS/front# cat package-lock.json | grep "webpack"
"webpack-bundle-analyzer": "3.0.3"
"autodll-webpack-plugin": {
"resolved": "https://registry.npmjs.org/autodll-webpack-plugin/-/autodll-webpack-plugin-0.4.2.tgz",
"webpack-merge": "^4.1.0",
"webpack-sources": "^1.0.1"
"compression-webpack-plugin": {
"resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-2.0.0.tgz",
"webpack-sources": "^1.0.1"
"autodll-webpack-plugin": "0.4.2",
"webpack": "4.29.0",
"webpack-dev-middleware": "3.6.0",
"webpack-hot-middleware": "2.24.3",
"webpack-sources": "1.3.0",
"webpack": {
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.29.0.tgz",
"terser-webpack-plugin": "^1.1.0",
"webpack-sources": "^1.3.0"
"webpack-sources": {
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz",
"terser-webpack-plugin": {
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz",
"webpack-sources": "^1.4.0",
"webpack": {
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.42.1.tgz",
"terser-webpack-plugin": "^1.4.3",
"webpack-sources": "^1.4.1"
"webpack-ant-icon-loader": {
"resolved": "https://registry.npmjs.org/webpack-ant-icon-loader/-/webpack-ant-icon-loader-1.0.8.tgz",
"webpack-bundle-analyzer": {
"resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.0.3.tgz",
"webpack-cli": {
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.11.tgz",
"webpack-dev-middleware": {
"resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-3.6.0.tgz",
"webpack-log": "^2.0.0"
"webpack-hot-middleware": {
"resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.24.3.tgz",
"webpack-log": {
"resolved": "https://registry.npmjs.org/webpack-log/-/webpack-log-2.0.0.tgz",
"webpack-merge": {
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz",
"webpack-sources": {
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz",
///////////////////////////////////