简体   繁体   English

Heroku - 部署时 package.json 中未指定节点版本

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

I was deploying my React app to Heroku but was getting this error while deploying.我正在将我的 React 应用程序部署到 Heroku 但在部署时遇到此错误。 When i run the code locally it's running fine.当我在本地运行代码时,它运行良好。 This is the Heroku build log for refrence.这是 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

I checked package.json but didnt found any mistake This is a part of Package.json file我检查了 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"
  }
}

Please let me know where is the problem here请让我知道问题出在哪里

You should precise which version of node you want to use to run your app and add the following to your package.json:您应该确定要使用哪个版本的节点来运行您的应用程序,并将以下内容添加到您的 package.json:

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

Adapt the value to your need.根据您的需要调整值。

remove packages-lock.json and run again the node js app删除 packages-lock.json 并再次运行节点 js 应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Heroku buildpack 马忽略 package.json 中的节点版本 - Heroku buildpack horse ignoring node version in package.json 使用 2 个 package.json 文件在 Heroku 上部署时出现问题 - Problem with deployment on Heroku with 2 package.json files Heroku使用较旧版本的package.json构建 - Heroku builds with a older version of package.json 在 AWS 上部署应用程序时,在 package.json 中指定节点 js 版本 - Specify node js version in package.json at time of application deployment on aws Package.json指定节点版本,但Azure告诉我没有指定 - Package.json specifies Node version but Azure tells me none is specified Google App Engine上的node.js:运行版本与package.json中指定的版本不同 - node.js on google app engine: different version running vs specified in package.json Heroku停留在Node v0.10.30上(但是package.json要求提供当前版本) - Heroku stuck at Node v0.10.30 (but package.json asks for current version) npm install package.json 中指定的确切包版本 - npm install the exact package version specified in package.json 推送到Heroku时出错:找不到模块“ node-linux-x64 / package.json” - Error while pushing to Heroku: Cannot find module 'node-linux-x64/package.json' package.json中指定的Mongodb版本无法安装 - Mongodb version specified in package.json fails to install
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM