ошибка при перемещении узла js project в heroku - PullRequest
0 голосов
/ 14 ноября 2018

Я получаю эту ошибку, когда пытаюсь перенести свой проект на heroku.Бэкэнд написан в nodeJS, интерфейс в React.Я думаю, что проблема в Heroku-Postbuild, потому что, если я удаляю его, push работает.Я искал это, но все еще не знаю, в чем причина.Кто-нибудь может мне помочь?

/tmp/build_7504975f08f330415cdefb27437cfad9/node_modules/.bin/node: 1: /tmp/build_7504975f08f330415cdefb27437cfad9/node_modules/.bin/node: MZ����@: not found
/tmp/build_7504975f08f330415cdefb27437cfad9/node_modules/.bin/node: 1: /tmp/build_7504975f08f330415cdefb27437cfad9/node_modules/.bin/node: Syntax error: word unexpected (expecting ")")
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! project@1.0.0 heroku-postbuild: `cd client && npm install && npm run build`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the project@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.W89m8/_logs/2018-11-13T21_37_22_676Z-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_modules checked into source control
         https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits

       - 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

package.json (сервер)

    {
      "name": "project",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "node server.js",
        "server": "nodemon server.js",
        "client-install": "npm install --prefix client",
        "client": "npm start --prefix client",
        "dev": "concurrently \"npm run server\" \"npm run client\"",
        "heroku-postbuild": "cd client && npm install && npm run build"
      },

      "author": "",
      "license": "ISC",
      "dependencies": {
        "concurrently": "^4.0.1",
        "express": "^4.16.4",
        "jsonwebtoken": "^8.3.0",
        "mongoose": "^5.3.4",
        "node": "^8.10.0",
        "nodemon": "^1.18.4",
        "passport": "^0.4.0",
        "passport-jwt": "^4.0.0",
        "react-scripts": "1.0.11",
      },
      "devDependencies": {
        "nodemon": "^1.18.4",
        "react-scripts": "1.0.11"
      }
    }

package.json (клиент)

{
      "name": "client",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "parallelshell": "^3.0.2",
        "react-dom": "^16.5.2",
        "react-redux": "^5.0.7",
        "react-router": "^4.3.1",
        "react-router-dom": "^4.3.1",
        "react-router-redux": "^4.0.8",
        "react-scripts": "2.0.5",
        "socket.io-client": "^1.7.3",
      },
      "scripts": {
        "start": "parallelshell \"react-scripts start\" \"sass --watch src/styles/scss:src/styles/css --style compressed\"",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject",
        "sass": "sass --watch src/styles/scss:src/styles/css --style compressed",
        "sass-nw": "sass src/styles/scss:src/styles/css"
      },
      "proxy": "http://localhost:5000/",
    }

1 Ответ

0 голосов
/ 01 января 2019

Я столкнулся с подобной ошибкой при устранении неполадок в проекте. Я решил, используя предложения из приглашения.

       Some possible problems:

   - node_modules checked into source control
     https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits

   - Node version not specified in package.json
     https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

Так что попробуйте выполнить «rm -rf node_modules» в корневом каталоге, если вы зарегистрировали node_modules в хранилище. Heroku установит node_modules в развернутой среде и не нуждается в проверенной версии.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...