heroku를 이용한 배포 과정 중, node, npm 버전을 명시하지 않아 발생한 에러

JH.P·2022년 6월 14일
0
  • heroku와 github 연동 기능이 heroku 측의 내부 서버 문제로 한동안 작동하지 않았었다.
  • 오랜만에 heroku에 다시 들어가 깃허브에 연동해보았는데, 해당 문제가 해결이 되어 정상적으로 다시 작동했다.
  • 다시 깃허브에 연결하고, 수동으로 지금까지 백엔드 작업했던 것을 배포하는데, 아래와 같은 에러가 발생하였다.
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 16.x...
       Downloading and installing node 16.15.1...
       Using default npm version: 8.11.0
       
-----> Restoring cache
       Cached directories were not restored due to a change in version of node, npm, yarn or stack
       Module installation may take longer for this build
       
-----> Installing dependencies
       Installing node modules
       npm ERR! Invalid Version: ^6.2.0
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.Dqlzx/_logs/2022-06-14T02_49_26_544Z-debug-0.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

- 위에서부터 천천히 읽어보니 node와 npm버전을 인식하지 못해서 자체적으로 16.15.1, 8.11.0버전로 임의 설정하여 진행하다가 발생한 오류라는 생각이 들었다.

  • 따라서 해당 오류 로그에서 제공하는 트러블 슈팅 문서로 이동하여 해결할 내용을 확인해보았다.
    https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
  • 해당 문서에서는 프로젝트 경로의 package.json에 npm, node의 버전을 명시하는 법이 나와있다. 차근 차근 따라해보았다.
  • package.json으로 이동하여 아래와 같이 작성하였다.
  "version": "1.0.0",
  "description": "",
  "engines": {
    "node": "16.13.0",
    "npm": "8.1.0"
  },

깃허브에 push하고, 배포를 진행해보니 정상적으로 배포되었다.

profile
꾸준한 기록

0개의 댓글