推送到Heroku

时间:2019-05-09 06:18:31

标签: javascript node.js heroku shopify-app

我是编码的新手,根据本教程,我目前正在使用Node.js为Shopify开发嵌入式应用程序。 (https://developers.shopify.com/tutorials/build-a-shopify-app-with-node-and-react

我的应用程序在本地运行良好,但在推送到Heroku时无法构建。我已经尝试了所有可以在网上找到的解决方案,但这些解决方案均无效。 看来我的代码中有语法错误,但是我已经删除了那一部分,为什么错误仍然存​​在?

-----> Build
       Running build

       > collection-generator-app@1.0.0 build /tmp/build_9491321e44d82596e81efddc7086d165
       > next build

       Creating an optimized production build ...

Failed to compile.
./pages/fetch-query.js
SyntaxError: /tmp/build_9491321e44d82596e81efddc7086d165/pages/fetch-query.js: Unterminated JSX contents (34:9)
  32 | 
  33 |          return (
> 34 |              <div>
     |                   ^
  35 |               
  36 |          );
  37 |      }}
> Build error occurred
Error: > Build failed because of webpack errors
    at Object.build [as default] (/tmp/build_9491321e44d82596e81efddc7086d165/node_modules/next/dist/build/index.js:101:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! collection-generator-app@1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the collection-generator-app@1.0.0 build 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.Galdd/_logs/2019-05-09T04_23_39_145Z-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": "collection-generator-app",
  "version": "1.0.0",
  "description": "",
  "engines": {
    "node": "10.15.2",
    "npm": "6.4.1"
  },
  "main": "index.js",
  "scripts": {
    "dev": "node server.js",
    "start": "next start",
    "build": "next build"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@shopify/koa-shopify-auth": "^3.1.18",
    "@shopify/koa-shopify-graphql-proxy": "^2.1.5",
    "@shopify/polaris": "^3.11.0",
    "@zeit/next-css": "^1.0.1",
    "apollo-boost": "^0.3.1",
    "dotenv": "^7.0.0",
    "graphql": "^14.1.1",
    "isomorphic-fetch": "^2.2.1",
    "js-cookie": "^2.2.0",
    "js-cookies": "^1.0.4",
    "koa": "^2.7.0",
    "koa-session": "^5.10.1",
    "next": "^8.0.3",
    "react": "^16.8.4",
    "react-apollo": "^2.5.3",
    "react-dom": "^16.8.4"
  }
}

2 个答案:

答案 0 :(得分:0)

fetch-query.js文件中的div标签应该有一个结束标签。

如果您已经这样做,请提交更改并推送到heroku。 通常,您可以:

  • git add .
  • git commit -m "fix closing tag"
  • git push heroku master

但这取决于您如何配置git。

如果要保留div标签,请查看the Fragments API

答案 1 :(得分:0)

根据日志,您缺少一个封闭的html div标签。

解决方案:

  1. 删除第32行,或
  2. 在第32行或您认为结束的位置添加。

然后遵循@Nino编写的命令:

git add .
git commit -m "fix closing tag"
git push heroku master

就是这样。 :)

还建议您在.gitignore中包括/ node_modules。另外,在包json中包含您的版本。诸如heroku之类的某些模块最适合与节点8.0 +

一起使用
相关问题