簡體   English   中英

Heroku - 部署時 package.json 中未指定節點版本

[英]Heroku - Node version not specified in package.json while deployment

我正在將我的 React 應用程序部署到 Heroku 但在部署時遇到此錯誤。 當我在本地運行代碼時,它運行良好。 這是 Heroku 構建日志供參考。

-----> Building on the Heroku-20 stack
-----> Using buildpack: https://github.com/mars/create-react-app-buildpack
-----> React.js (create-react-app) multi app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-multi.git
=====> Detected Framework: Multipack
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
=====> Detected Framework: Node.js
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.18.2...
       Using default npm version: 6.14.15
       
-----> Installing dependencies
       Installing node modules
       npm ERR! bindings not accessible from watchpack-chokidar2:fsevents
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.4mm12/_logs/2022-01-09T12_08_27_820Z-debug.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 React.js (create-react-app) multi app.
 !     Push failed

我檢查了 package.json 但沒有發現任何錯誤這是 Package.Z466DEEC76ECDF5FCA6D4D3875 文件的一部分

{
  "name": "portfolio",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.6",
    "@testing-library/react": "^11.2.2",
    "@testing-library/user-event": "^12.6.0",
    "axios": "^0.21.1",
    "bootstrap": "^4.5.3",
    "node": "16.x",
    "react": "^17.0.1",
    "react-bootstrap": "^1.4.0",
    "react-dom": "^17.0.1",
    "react-github-calendar": "^2.0.2",
    "react-icons": "^4.2.0",
    "react-parallax-tilt": "^1.4.68",
    "react-particles-js": "^3.4.1",
    "react-pdf": "^5.4.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.1",
    "typewriter-effect": "^2.17.0",
    "web-vitals": "^0.2.4"
  }
}

請讓我知道問題出在哪里

您應該確定要使用哪個版本的節點來運行您的應用程序,並將以下內容添加到您的 package.json:

  "engines": {
    "node": "14.17.5"
  }

根據您的需要調整值。

刪除 packages-lock.json 並再次運行節點 js 應用程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM