기본 배포 yml을 사용했을 경우 에러가 발생했다. 아래는 에러 메시지.
예전에 Azure에서 배포했던 yml 파일을 참고해서 변경했다.
2022-10-07T05:00:36.047Z [WARNING]: !Failed to set up process.env.secrets
2022-10-07T05:00:36.176Z [INFO]: No live updates for this build run
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
preBuild 과정에서 command 를 npm ci 에서 npm install로 변경하고,
build command에 —if-present 를 추가해줬다.
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run build --if-present
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
변경하니 또 다른 에러가 났다.
2022-10-07T05:39:15.259Z [INFO]: Creating an optimized production build...
2022-10-07T05:39:40.022Z [INFO]: Failed to compile.
2022-10-07T05:39:40.024Z [INFO]: ./node_modules/react-apexcharts/dist/react-apexcharts.min.js
Cannot find module: 'apexcharts/dist/apexcharts.common'. Make sure this package is installed.
You can install this package by running: npm install apexcharts/dist/apexcharts.common.
2022-10-07T05:39:40.054Z [WARNING]: npm
2022-10-07T05:39:40.055Z [WARNING]: ERR! code ELIFECYCLE
npm ERR! errno 1
2022-10-07T05:39:40.057Z [WARNING]: npm ERR!
2022-10-07T05:39:40.057Z [WARNING]: wiznet-cloud-design@3.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wiznet-cloud-design@3.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-10-07T05:39:40.066Z [WARNING]:
2022-10-07T05:39:40.066Z [WARNING]: npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-10-07T05_39_40_057Z-debug.log
2022-10-07T05:39:40.066Z [HELP]: Outputting the npm debug log
[object Promise]
2022-10-07T05:39:40.069Z [ERROR]: !!! Build failed
2022-10-07T05:39:40.069Z [ERROR]: !!! Non-Zero Exit Code detected
2022-10-07T05:39:40.069Z [INFO]: # Starting environment caching...
2022-10-07T05:39:40.070Z [INFO]: # Environment caching completed
프로젝트에서 아래 명령어를 실행하고 다시 배포하니 정상적으로 배포되었다
npm install --save react-apexcharts apexcharts
참조
https://github.com/apexcharts/react-apexcharts/issues/139
https://stackoverflow.com/questions/72558170/module-not-found-cant-resolve-apexcharts-dist-apexcharts-common-apex-chart-m