HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🌟
Programmers 최종 플젝 6조
/
[프론트] TWL
[프론트] TWL
/
The npm ci command can only install with an existing package-lock.json
The npm ci command can only install with an existing package-lock.json
The npm ci command can only install with an existing package-lock.json

The npm ci command can only install with an existing package-lock.json

생성일
Dec 15, 2021 08:45 AM
태그
Git
CI
ESLint
Issue
작성자
해결 완료
해결 완료

🔥 문제

다음과 같이, CI를 설정하던 도중 npm ci가 불가능하다는 오류가 발생했다.
이전 프로젝트에서는 잘 적용되었으나 현재는 package-lock.json이 없다는 이유로 동작하지 않는 듯하다.
확인해보니, 예전 프로젝트에서도 package-lock.json과 yarn-lock으로 분리가 됐더라.
이를 어떻게 해결해줄 수 있을까?
기존의 코드는 다음과 같았다.
name: CI-front on: push: branches: [ develop, main ] pull_request: branches: [ develop, main ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [16.x] steps: - name: Check out repository uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install a project with a clean slate run: npm ci - name: Lint run: npm run lint - uses: actions/checkout@v2 - name: Install Dependencies working-directory: ./ run: yarn install - name: Build ReactJS env: CI: false working-directory: ./ run: yarn run build - name: Login to DockerHub uses: docker/login-action@v1.8.0 with: username: ${{ secrets.DOCKERHUB_FRONT_USERNAME }} password: ${{ secrets.DOCKERHUB_FRONT_PASSWORD }} - name: Build and push Docker images uses: docker/build-push-action@v2.4.0 with: context: . file: Dockerfile push: true tags: ${{ secrets.DOCKERHUB_FRONT_USERNAME }}/kazedon_fe:latest
 

⭐ 해결 방법

핵심은 yarn으로 어떻게 npm ci를 대체할 수 있냐는 것이었다.
yarn의 경우, ci라는 것이 따로 없고, 실제로 다음과 같은 커맨드가 가장 효과적으로 npm ci를 따라한다고 한다.

👏🏻 참고자료

https://medium.com/@trustyoo86/ci-환경을-위한-npm-ci-npm-ci-for-continous-integration-850fc48dd4cc