도커 빌드 과정에서 발생한 'axios' 에러 발생

이유진·2022년 2월 22일
0

docker-compose up --build

했을때, 오류 메세지는
Module not found: Error: Can't resolve 'axios' in '/app/src' frontend_1 | resolve 'axios' in '/app/src'
같은데....
frontend 의 package.json에

로 axios 버전을 추가시켰는데도 에러메세지 변화 없음

frontend_1  | (node:25) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
frontend_1  | (Use `node --trace-deprecation ...` to show where the warning was created)
frontend_1  | (node:25) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
frontend_1  | Starting the development server...
frontend_1  | 
frontend_1  | Failed to compile.
frontend_1  | 
frontend_1  | Module not found: Error: Can't resolve 'axios' in '/app/src'
frontend_1  | assets by path static/ 1.49 MiB
frontend_1  |   asset static/js/bundle.js 1.48 MiB [emitted] (name: main) 1 related asset
frontend_1  |   asset static/js/node_modules_web-vitals_dist_web-vitals_js.chunk.js 6.92 KiB [emitted] 1 related asset
frontend_1  |   asset static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg 2.57 KiB [emitted] (auxiliary name: main)
frontend_1  | asset index.html 1.67 KiB [emitted]
frontend_1  | asset asset-manifest.json 546 bytes [emitted]
frontend_1  | runtime modules 31.3 KiB 15 modules
frontend_1  | modules by path ./node_modules/ 1.35 MiB 99 modules
frontend_1  | modules by path ./src/ 19.7 KiB
frontend_1  |   modules by path ./src/*.css 8.82 KiB
frontend_1  |     ./src/index.css 2.72 KiB [built] [code generated]
frontend_1  |     ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/index.css 1.37 KiB [built] [code generated]
frontend_1  |     ./src/App.css 2.72 KiB [built] [code generated]
frontend_1  |     ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/App.css 2 KiB [built] [code generated]
frontend_1  |   modules by path ./src/*.js 7.27 KiB
frontend_1  |     ./src/index.js 1.73 KiB [built] [code generated]
frontend_1  |     ./src/App.js 4.19 KiB [built] [code generated]
frontend_1  |     ./src/reportWebVitals.js 1.36 KiB [built] [code generated]
frontend_1  |   ./src/logo.svg 3.61 KiB [built] [code generated]
frontend_1  | 
frontend_1  | ERROR in ./src/App.js 9:0-26
frontend_1  | Module not found: Error: Can't resolve 'axios' in '/app/src'
frontend_1  | resolve 'axios' in '/app/src'
frontend_1  |   Parsed request is a module
frontend_1  |   using description file: /app/package.json (relative path: ./src)
frontend_1  |     Field 'browser' doesn't contain a valid alias configuration
frontend_1  |     resolve as module
frontend_1  |       /app/src/node_modules doesn't exist or is not a directory
frontend_1  |       looking for modules in /app/node_modules
frontend_1  |         single file module
frontend_1  |           using description file: /app/package.json (relative path: ./node_modules/axios)
frontend_1  |             no extension
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios doesn't exist
frontend_1  |             .web.mjs
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.web.mjs doesn't exist
frontend_1  |             .mjs
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.mjs doesn't exist
frontend_1  |             .web.js
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.web.js doesn't exist
frontend_1  |             .js
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.js doesn't exist
frontend_1  |             .json
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.json doesn't exist
frontend_1  |             .web.jsx
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.web.jsx doesn't exist
frontend_1  |             .jsx
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.jsx doesn't exist
frontend_1  |         /app/node_modules/axios doesn't exist
frontend_1  |       /node_modules doesn't exist or is not a directory
frontend_1  |       looking for modules in /app/node_modules
frontend_1  |         single file module
frontend_1  |           using description file: /app/package.json (relative path: ./node_modules/axios)
frontend_1  |             no extension
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios doesn't exist
frontend_1  |             .web.mjs
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.web.mjs doesn't exist
frontend_1  |             .mjs
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.mjs doesn't exist
frontend_1  |             .web.js
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.web.js doesn't exist
frontend_1  |             .js
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.js doesn't exist
frontend_1  |             .json
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.json doesn't exist
frontend_1  |             .web.jsx
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.web.jsx doesn't exist
frontend_1  |             .jsx
frontend_1  |               Field 'browser' doesn't contain a valid alias configuration
frontend_1  |               /app/node_modules/axios.jsx doesn't exist
frontend_1  |         /app/node_modules/axios doesn't exist
frontend_1  |  @ ./src/index.js 7:0-24 11:33-36
frontend_1  | 
frontend_1  | webpack 5.69.1 compiled with 1 error in 5061 ms

[해결!]

frontend의 dockerfile을 빌들할 때, "axios"를 빌드하지 못하는 것으로 판단하여
dockerfile에 추가로 axios를 설치하였다.

run npm install axios을 진행하니 정상적으로 작동하였다.

+) 추가로,
run npm install axios를 추가로 작성하여, 정상작동 후 해당 명령어를 삭제 후 재빌드했을땐 이미 캐시된 파일로 빌드되었다.

profile
차근차근 배워나가는 주니어 개발자

0개의 댓글