Heroku拒绝,无法编译nodejs。 React,Node.js,Express框架

时间:2019-02-24 14:14:13

标签: node.js reactjs heroku

我正在尝试推送我的nodejs,表达(后端)并做出反应(字体结尾) git push heroku master。

但已拒绝:

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  10.15.1
       engines.npm (package.json):   6.4.1

       Resolving node version 10.15.1...
       Downloading and installing node 10.15.1...
       npm 6.4.1 already installed with node

-----> Restoring cache
       - node_modules

-----> Building dependencies
       Installing node modules (package.json)
       removed 231 packages and audited 201 packages in 3.657s
       found 0 vulnerabilities

       Running heroku-postbuild

       > twituet@1.0.0 heroku-postbuild /tmp/build_fcf0465a8c2c68ad9a71497722565a7a
       > cd client && npm && npm run build


       Usage: npm <command>

       where <command> is one of:
           access, adduser, audit, bin, bugs, c, cache, ci, cit,
           completion, config, create, ddp, dedupe, deprecate,
           dist-tag, docs, doctor, edit, explore, get, help,
           help-search, hook, i, init, install, install-test, it, link,
           list, ln, login, logout, ls, outdated, owner, pack, ping,
           prefix, profile, prune, publish, rb, rebuild, repo, restart,
           root, run, run-script, s, se, search, set, shrinkwrap, star,
           stars, start, stop, t, team, test, token, tst, un,
           uninstall, unpublish, unstar, up, update, v, version, view,
           whoami

       npm <command> -h  quick help on <command>
       npm -l            display full usage info
       npm help <term>   search for help on <term>
       npm help npm      involved overview

       Specify configs in the ini-formatted file:
           /app/.npmrc
       or on the command line via: npm <command> --key value
       Config info can be viewed via: npm help config

       npm@6.4.1 /tmp/build_fcf0465a8c2c68ad9a71497722565a7a/.heroku/node/lib/node_modules/npm
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! twituet@1.0.0 heroku-postbuild: `cd client && npm && npm run build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the twituet@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.x0XkK/_logs/2019-02-24T14_05_47_120Z-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

       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/

       Love,
       Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed

这是我的package.json

{
    "name": "twituet",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "node index.js",
        "heroku-postbuild": "cd client && npm && npm run build"
    },
    "keywords": [],
    "author": "vuong xuan",
    "license": "ISC",
    "dependencies": {
        "body-parser": "^1.18.3",
        "cors": "^2.8.5",
        "express": "^4.16.4",
        "mongoose": "^5.4.14",
        "morgan": "^1.9.1"
    },
    "engines": {
        "node": "10.15.1",
        "npm": "6.4.1"
    }
}

我做错了。请帮我...

我尝试了此解决方案,但没有成功 Push rejected, failed to compile Node.js app heroku

2 个答案:

答案 0 :(得分:2)

由于您正在执行npm命令,而没有传递任何失败的参数。

查看此行"heroku-postbuild": "cd client && npm && npm run build"

并将其更改为"heroku-postbuild": "cd client && npm install && npm run build"

npm <command>npm命令的正确格式。

有关更多详细信息,请参阅npm文档-https://docs.npmjs.com/cli/npm

答案 1 :(得分:0)

使用"heroku-postbuild": "echo Skip builds on Heroku"

这解决了我的问题!