• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

aws 에서 front 빌드 시 에러가 뜨는데 해매고 있습니다..

22.03.04 09:10 작성 조회수 489

0

Error: Parsing error: Must use import to load ES Module: /home/ubuntu/new-node-bird-std/front/node_modules/eslint-scope/lib/definition.js

require() of ES modules is not supported.

require() of /home/ubuntu/new-node-bird-std/front/node_modules/eslint-scope/lib/definition.js from /home/ubuntu/new-node-bird-std/front/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.

Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/ubuntu/new-node-bird-std/front/node_modules/eslint-scope/package.json.

 

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! react-nodebird-front@1.0.0 build: `cross-env ANALYZE=true NODE_ENV=production 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!     /home/ubuntu/.npm/_logs/2022-03-04T00_05_27_105Z-debug.log

 

AWS 에서 front 쪽 빌드 시 위의 에러가 발생하는데 
로컬에선 빌드가 되서 .next gitignore 풀고 github에 올리려 하니 용량 문제가 있는지 그마저도 업로드가 안됩니다.

답변 2

·

답변을 작성해보세요.

0

af8000님의 프로필

af8000

질문자

2022.03.07

{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": [
"airbnb",
"eslint:recommended",
"next"
],
"plugins": [
"import",
"react-hooks"
],
"rules": {
"jsx-a11y/label-has-associated-control": "off",
"jsx-a11y/anchor-is-valid": "off",
"no-console": "off",
"no-underscore-dangle": "off",
"react/forbid-prop-types": "off",
"react/jsx-filename-extension": "off",
"react/jsx-one-expression-per-line": "off",
"object-curly-newline": "off",
"linebreak-style": "off",
"no-param-reassign": "off"
}
}

 

 

{
"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": "yodafolio",
"license": "ISC",
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@next/bundle-analyzer": "^12.1.0",
"antd": "^4.16.13",
"axios": "^0.24.0",
"cross-env": "^7.0.3",
"faker": "^5.5.3",
"immer": "^9.0.7",
"moment": "^2.29.1",
"next": "^12.0.4",
"next-redux-wrapper": "^7.0.5",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"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.1"
},
"devDependencies": {
"@next/eslint-plugin-next": "^12.1.0",
"babel-eslint": "^10.1.0",
"babel-plugin-styled-components": "^1.13.3",
"eslint": "^8.10.0",
"eslint-config-airbnb": "^19.0.1",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0"
}
}

0

eslintrc 랑 package.json 올려주세요.

af8000님의 프로필

af8000

질문자

2022.03.07

혹시 제 로컬의 node -v는
14.17.0 & npm -v 8.3.0 이고
우분투에 설치된 node -v는
14.19.0 & npm -v 6.14.16 인데 여기서 영향이 있을 수도 있나요..?

(eslintrc 랑 package.json는 아래의 댓글에 적어놨습니다~!)

af8000님의 프로필

af8000

질문자

2022.03.07

제로초님, 제가 nvm으로 노드를 설치하여 node 버전 및 nvm install-latest-install로 npm 버전을 저의 로컬 npm 버전과 맞춰준 다음

린트 rules 에 

"react/no-unescaped-entities": "off",
"@next/next/no-page-custom-font": "off"

를 추가 하고 나니, 빌드가 되긴 됩니다..! 둘중에 어떤게 원인 인지는 모르겠어서 둘다 적용해 놓으니 되네요; 하나씩 빼보면서 테스트 해보겠습니다;

일단 npm 버전 차이가 가장 의심 스럽긴 한거 같아요..

일단 제가 봤을때는 eslint 버전도 8이라서 강좌의 7보다 높아 사용법이 다를 수 있습니다.