node.js - Reactjs : Unable to push to Heroku

标签 node.js git heroku

我正在尝试将 Reactjs 应用程序推送到 Heroku。

这是我的package.json 文件:

{
  "name": "redux-simple-starter",
  "version": "1.0.0",
  "description": "Simple starter package for Redux with React and Babel support",
  "main": "index.js",
  "repository": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="35525c4175525c415d40571b565a58" rel="noreferrer noopener nofollow">[email protected]</a>:ldco2016/efUtube.git",
  "scripts": {
    "dev": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "postinstall": "webpack -p",
    "start": "node server.js",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
    "test:watch": "npm run test -- --watch"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",
    "chai": "^3.5.0",
    "chai-jquery": "^2.0.0",
    "jquery": "3.0.0",
    "jsdom": "^8.1.0",
    "mocha": "^2.4.5",
    "react-addons-test-utils": "^0.14.7",
    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "babel-preset-stage-1": "^6.1.18",
    "lodash": "^3.10.1",
    "node": "9.4.0",
    "react": "^0.14.3",
    "react-dom": "^0.14.3",
    "react-redux": "^4.0.0",
    "react-router": "^2.0.1",
    "redux": "^3.0.4",
    "youtube-api-search": "0.0.5"
  }
}

我进行了:

npm install -g webpack 以及 webpack -p

我创建了一个 server.js 文件并使用以下代码完成它:

const express = require('express');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();

app.use(express.static(__dirname));

app.get('*', (req, res) => {
  res.sendFile(path.resolve(__dirname, 'index.html'))
});

app.listen(port);
console.log('Server started');

当我在命令行中运行 node server.js 时,它在本地工作,但是当提交并推送更改并运行时:

git push heroku master 我反复收到此错误:

remote: /app/tmp/buildpacks/19862b8792e84bd8421ded4660b92dfd1c41d92e19ac0b38c90301adc8ae3e0bd512fa01998af18fc2f0d31a157e9c82e8fdceba1a05e5d29adb8dc2bfaf08e1/lib/failure.sh: line 282: greq: command not found
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        Some possible problems:
remote:
remote:        - Node version not specified in package.json
remote:        https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:

最佳答案

使用此命令node -v检查您的 Node 版本,并使用此命令npm -v检查npm版本, 然后在 package.json 中指定 Node 和 npm 版本,如下所示:

“引擎”:{ “Node ”:“8.1.x”, “npm”:“5.0.x” },

确保在依赖项和 devDependency 列表之前指定它。

关于node.js - Reactjs : Unable to push to Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48472511/

相关文章:

node.js - 如果数据库连接断开,为什么 db.collection().find().toArray(callback) 中的回调不会被调用?

node.js - 如何在更新 Amazon DynamoDB 中的项目时执行多个操作?

Gitlab:每个用户的搜索提交

python - 如何从 Python 中调用 'git pull'?

git - merge 时存储

postgresql - Heroku 托管 PostgreSQL 和 PLV8

windows - 如何编辑我的 .git/config 文件?

node.js - 使用sequelize.js 检查记录/模型是否唯一

node.js - 在服务器路径中获取带有冒号和问号的方法

php - Laravel 产品,CORS 编号 'Access-Control-Allow-Origin' header