NodeJS deploying with webpack to Heroku: Build failed with error code: 1










-1














I'm having difficulty deploying a react/webpack app with Heroku that works locally without any issues. When I try deploying it a get a large string of text that ends in "Build failed with error code: 1" and then "error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'". I'm not really sure where the issue is coming from so I've attached my server.js and package.json, please let me know if I'm missing any information that would be helpful. Not sure if its relevant but usually I work with Linux but lately I've been working on Windows. Thanks



edit: updated package json with engines field as suggested



package.json (updated with engine field)




"name": "enerjee-website",
"version": "1.0.0",
"engines":
"node": "8.11.2",
"yarn": "1.7.0",
"npm": "5.6.0"
,
"main": "index.js",
"author": "Sonam",
"license": "",
"scripts":
"serve": "live-server public/",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"start": "node server/server.js",
"heroku-postbuild": "yarn run build:prod"
,
"dependencies":
"@fortawesome/fontawesome-free": "^5.4.2",
"@fortawesome/fontawesome-svg-core": "^1.2.8",
"@fortawesome/free-brands-svg-icons": "^5.5.0",
"@fortawesome/free-solid-svg-icons": "^5.5.0",
"@fortawesome/react-fontawesome": "^0.1.3",
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-loader": "7.1.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"bootstrap": "^4.1.3",
"css-loader": "0.28.4",
"express": "^4.16.3",
"jquery": "^3.3.1",
"live-server": "^1.2.0",
"node-sass": "4.5.3",
"normalize.css": "7.0.0",
"popper.js": "^1.14.4",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-modal": "2.2.2",
"react-router-dom": "4.1.2",
"sass-loader": "6.0.6",
"style-loader": "0.18.2",
"validator": "8.0.0",
"webpack": "3.1.0",
"webpack-dev-server": "2.5.1"
,
"devDependencies":
"file-loader": "^2.0.0",
"image-webpack-loader": "^4.3.1"




server.js



const path = require('path');
const express = require('express');
const app = express();
const publicPath = path.join(__dirname, '..', 'public');
const port = process.env.PORT || 3000;

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

app.get('*', (req, res) =>
res.sendFile(path.join(publicPath, 'index.html'));
);

app.listen(port, () =>
console.log('Server is up on' + port);
);


Error text after adding engines



remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.x|10.x
remote: engines.npm (package.json): unspecified (use default)
remote: engines.yarn (package.json): unspecified (use default)
remote:
remote: Resolving node version 8.x|10.x...
remote: Error: Invalid semantic version "8.x|10.x"
remote:
remote: -----> Build failed
remote:
remote: ! Invalid semver requirement
remote:
remote: Node, Yarn, and npm adhere to semver, the semantic versioning convention
remote: popularized by GitHub.
remote:
remote: http://semver.org/
remote:
remote: However you have specified a version requirement that is not a valid
remote: semantic version.
remote:
remote: https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-invalid-semver-requirement
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to vast-wildwood-63128.
remote:
To https://git.heroku.com/vast-wildwood-63128.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'









share|improve this question



















  • 2




    I love how it shows "Some possible problems:", with a link to: devcenter.heroku.com/articles/…, which says exactly what @zakaria wrote in his answer below.
    – FrankerZ
    Nov 12 '18 at 5:58










  • yeah i originally just assumed that was a generic error suggestion as all the project I've previously deployed to Heroku didn't require an engines field
    – Sonam
    Nov 13 '18 at 5:32















-1














I'm having difficulty deploying a react/webpack app with Heroku that works locally without any issues. When I try deploying it a get a large string of text that ends in "Build failed with error code: 1" and then "error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'". I'm not really sure where the issue is coming from so I've attached my server.js and package.json, please let me know if I'm missing any information that would be helpful. Not sure if its relevant but usually I work with Linux but lately I've been working on Windows. Thanks



edit: updated package json with engines field as suggested



package.json (updated with engine field)




"name": "enerjee-website",
"version": "1.0.0",
"engines":
"node": "8.11.2",
"yarn": "1.7.0",
"npm": "5.6.0"
,
"main": "index.js",
"author": "Sonam",
"license": "",
"scripts":
"serve": "live-server public/",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"start": "node server/server.js",
"heroku-postbuild": "yarn run build:prod"
,
"dependencies":
"@fortawesome/fontawesome-free": "^5.4.2",
"@fortawesome/fontawesome-svg-core": "^1.2.8",
"@fortawesome/free-brands-svg-icons": "^5.5.0",
"@fortawesome/free-solid-svg-icons": "^5.5.0",
"@fortawesome/react-fontawesome": "^0.1.3",
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-loader": "7.1.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"bootstrap": "^4.1.3",
"css-loader": "0.28.4",
"express": "^4.16.3",
"jquery": "^3.3.1",
"live-server": "^1.2.0",
"node-sass": "4.5.3",
"normalize.css": "7.0.0",
"popper.js": "^1.14.4",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-modal": "2.2.2",
"react-router-dom": "4.1.2",
"sass-loader": "6.0.6",
"style-loader": "0.18.2",
"validator": "8.0.0",
"webpack": "3.1.0",
"webpack-dev-server": "2.5.1"
,
"devDependencies":
"file-loader": "^2.0.0",
"image-webpack-loader": "^4.3.1"




server.js



const path = require('path');
const express = require('express');
const app = express();
const publicPath = path.join(__dirname, '..', 'public');
const port = process.env.PORT || 3000;

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

app.get('*', (req, res) =>
res.sendFile(path.join(publicPath, 'index.html'));
);

app.listen(port, () =>
console.log('Server is up on' + port);
);


Error text after adding engines



remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.x|10.x
remote: engines.npm (package.json): unspecified (use default)
remote: engines.yarn (package.json): unspecified (use default)
remote:
remote: Resolving node version 8.x|10.x...
remote: Error: Invalid semantic version "8.x|10.x"
remote:
remote: -----> Build failed
remote:
remote: ! Invalid semver requirement
remote:
remote: Node, Yarn, and npm adhere to semver, the semantic versioning convention
remote: popularized by GitHub.
remote:
remote: http://semver.org/
remote:
remote: However you have specified a version requirement that is not a valid
remote: semantic version.
remote:
remote: https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-invalid-semver-requirement
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to vast-wildwood-63128.
remote:
To https://git.heroku.com/vast-wildwood-63128.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'









share|improve this question



















  • 2




    I love how it shows "Some possible problems:", with a link to: devcenter.heroku.com/articles/…, which says exactly what @zakaria wrote in his answer below.
    – FrankerZ
    Nov 12 '18 at 5:58










  • yeah i originally just assumed that was a generic error suggestion as all the project I've previously deployed to Heroku didn't require an engines field
    – Sonam
    Nov 13 '18 at 5:32













-1












-1








-1







I'm having difficulty deploying a react/webpack app with Heroku that works locally without any issues. When I try deploying it a get a large string of text that ends in "Build failed with error code: 1" and then "error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'". I'm not really sure where the issue is coming from so I've attached my server.js and package.json, please let me know if I'm missing any information that would be helpful. Not sure if its relevant but usually I work with Linux but lately I've been working on Windows. Thanks



edit: updated package json with engines field as suggested



package.json (updated with engine field)




"name": "enerjee-website",
"version": "1.0.0",
"engines":
"node": "8.11.2",
"yarn": "1.7.0",
"npm": "5.6.0"
,
"main": "index.js",
"author": "Sonam",
"license": "",
"scripts":
"serve": "live-server public/",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"start": "node server/server.js",
"heroku-postbuild": "yarn run build:prod"
,
"dependencies":
"@fortawesome/fontawesome-free": "^5.4.2",
"@fortawesome/fontawesome-svg-core": "^1.2.8",
"@fortawesome/free-brands-svg-icons": "^5.5.0",
"@fortawesome/free-solid-svg-icons": "^5.5.0",
"@fortawesome/react-fontawesome": "^0.1.3",
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-loader": "7.1.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"bootstrap": "^4.1.3",
"css-loader": "0.28.4",
"express": "^4.16.3",
"jquery": "^3.3.1",
"live-server": "^1.2.0",
"node-sass": "4.5.3",
"normalize.css": "7.0.0",
"popper.js": "^1.14.4",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-modal": "2.2.2",
"react-router-dom": "4.1.2",
"sass-loader": "6.0.6",
"style-loader": "0.18.2",
"validator": "8.0.0",
"webpack": "3.1.0",
"webpack-dev-server": "2.5.1"
,
"devDependencies":
"file-loader": "^2.0.0",
"image-webpack-loader": "^4.3.1"




server.js



const path = require('path');
const express = require('express');
const app = express();
const publicPath = path.join(__dirname, '..', 'public');
const port = process.env.PORT || 3000;

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

app.get('*', (req, res) =>
res.sendFile(path.join(publicPath, 'index.html'));
);

app.listen(port, () =>
console.log('Server is up on' + port);
);


Error text after adding engines



remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.x|10.x
remote: engines.npm (package.json): unspecified (use default)
remote: engines.yarn (package.json): unspecified (use default)
remote:
remote: Resolving node version 8.x|10.x...
remote: Error: Invalid semantic version "8.x|10.x"
remote:
remote: -----> Build failed
remote:
remote: ! Invalid semver requirement
remote:
remote: Node, Yarn, and npm adhere to semver, the semantic versioning convention
remote: popularized by GitHub.
remote:
remote: http://semver.org/
remote:
remote: However you have specified a version requirement that is not a valid
remote: semantic version.
remote:
remote: https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-invalid-semver-requirement
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to vast-wildwood-63128.
remote:
To https://git.heroku.com/vast-wildwood-63128.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'









share|improve this question















I'm having difficulty deploying a react/webpack app with Heroku that works locally without any issues. When I try deploying it a get a large string of text that ends in "Build failed with error code: 1" and then "error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'". I'm not really sure where the issue is coming from so I've attached my server.js and package.json, please let me know if I'm missing any information that would be helpful. Not sure if its relevant but usually I work with Linux but lately I've been working on Windows. Thanks



edit: updated package json with engines field as suggested



package.json (updated with engine field)




"name": "enerjee-website",
"version": "1.0.0",
"engines":
"node": "8.11.2",
"yarn": "1.7.0",
"npm": "5.6.0"
,
"main": "index.js",
"author": "Sonam",
"license": "",
"scripts":
"serve": "live-server public/",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"start": "node server/server.js",
"heroku-postbuild": "yarn run build:prod"
,
"dependencies":
"@fortawesome/fontawesome-free": "^5.4.2",
"@fortawesome/fontawesome-svg-core": "^1.2.8",
"@fortawesome/free-brands-svg-icons": "^5.5.0",
"@fortawesome/free-solid-svg-icons": "^5.5.0",
"@fortawesome/react-fontawesome": "^0.1.3",
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-loader": "7.1.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"bootstrap": "^4.1.3",
"css-loader": "0.28.4",
"express": "^4.16.3",
"jquery": "^3.3.1",
"live-server": "^1.2.0",
"node-sass": "4.5.3",
"normalize.css": "7.0.0",
"popper.js": "^1.14.4",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-modal": "2.2.2",
"react-router-dom": "4.1.2",
"sass-loader": "6.0.6",
"style-loader": "0.18.2",
"validator": "8.0.0",
"webpack": "3.1.0",
"webpack-dev-server": "2.5.1"
,
"devDependencies":
"file-loader": "^2.0.0",
"image-webpack-loader": "^4.3.1"




server.js



const path = require('path');
const express = require('express');
const app = express();
const publicPath = path.join(__dirname, '..', 'public');
const port = process.env.PORT || 3000;

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

app.get('*', (req, res) =>
res.sendFile(path.join(publicPath, 'index.html'));
);

app.listen(port, () =>
console.log('Server is up on' + port);
);


Error text after adding engines



remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.x|10.x
remote: engines.npm (package.json): unspecified (use default)
remote: engines.yarn (package.json): unspecified (use default)
remote:
remote: Resolving node version 8.x|10.x...
remote: Error: Invalid semantic version "8.x|10.x"
remote:
remote: -----> Build failed
remote:
remote: ! Invalid semver requirement
remote:
remote: Node, Yarn, and npm adhere to semver, the semantic versioning convention
remote: popularized by GitHub.
remote:
remote: http://semver.org/
remote:
remote: However you have specified a version requirement that is not a valid
remote: semantic version.
remote:
remote: https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-invalid-semver-requirement
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to vast-wildwood-63128.
remote:
To https://git.heroku.com/vast-wildwood-63128.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vast-wildwood-63128.git'






node.js reactjs heroku webpack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 5:28







Sonam

















asked Nov 12 '18 at 5:54









SonamSonam

11




11







  • 2




    I love how it shows "Some possible problems:", with a link to: devcenter.heroku.com/articles/…, which says exactly what @zakaria wrote in his answer below.
    – FrankerZ
    Nov 12 '18 at 5:58










  • yeah i originally just assumed that was a generic error suggestion as all the project I've previously deployed to Heroku didn't require an engines field
    – Sonam
    Nov 13 '18 at 5:32












  • 2




    I love how it shows "Some possible problems:", with a link to: devcenter.heroku.com/articles/…, which says exactly what @zakaria wrote in his answer below.
    – FrankerZ
    Nov 12 '18 at 5:58










  • yeah i originally just assumed that was a generic error suggestion as all the project I've previously deployed to Heroku didn't require an engines field
    – Sonam
    Nov 13 '18 at 5:32







2




2




I love how it shows "Some possible problems:", with a link to: devcenter.heroku.com/articles/…, which says exactly what @zakaria wrote in his answer below.
– FrankerZ
Nov 12 '18 at 5:58




I love how it shows "Some possible problems:", with a link to: devcenter.heroku.com/articles/…, which says exactly what @zakaria wrote in his answer below.
– FrankerZ
Nov 12 '18 at 5:58












yeah i originally just assumed that was a generic error suggestion as all the project I've previously deployed to Heroku didn't require an engines field
– Sonam
Nov 13 '18 at 5:32




yeah i originally just assumed that was a generic error suggestion as all the project I've previously deployed to Heroku didn't require an engines field
– Sonam
Nov 13 '18 at 5:32












1 Answer
1






active

oldest

votes


















0














You need to specify the node version in your package.json, so Heroku knows which node version to run.



e.g.



"engines": 10.x"
,


https://devcenter.heroku.com/articles/nodejs-support



Read specifying a node.js version section.






share|improve this answer




















  • Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
    – Sonam
    Nov 13 '18 at 5:26











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256553%2fnodejs-deploying-with-webpack-to-heroku-build-failed-with-error-code-1%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You need to specify the node version in your package.json, so Heroku knows which node version to run.



e.g.



"engines": 10.x"
,


https://devcenter.heroku.com/articles/nodejs-support



Read specifying a node.js version section.






share|improve this answer




















  • Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
    – Sonam
    Nov 13 '18 at 5:26
















0














You need to specify the node version in your package.json, so Heroku knows which node version to run.



e.g.



"engines": 10.x"
,


https://devcenter.heroku.com/articles/nodejs-support



Read specifying a node.js version section.






share|improve this answer




















  • Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
    – Sonam
    Nov 13 '18 at 5:26














0












0








0






You need to specify the node version in your package.json, so Heroku knows which node version to run.



e.g.



"engines": 10.x"
,


https://devcenter.heroku.com/articles/nodejs-support



Read specifying a node.js version section.






share|improve this answer












You need to specify the node version in your package.json, so Heroku knows which node version to run.



e.g.



"engines": 10.x"
,


https://devcenter.heroku.com/articles/nodejs-support



Read specifying a node.js version section.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 5:57









zakariazakaria

62




62











  • Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
    – Sonam
    Nov 13 '18 at 5:26

















  • Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
    – Sonam
    Nov 13 '18 at 5:26
















Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
– Sonam
Nov 13 '18 at 5:26





Thanks for the reply. I checked the link and tried adding the versions in the engine field but unfortunately the build now fails with a different error. I've updated the original question with the new package.json and error
– Sonam
Nov 13 '18 at 5:26


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256553%2fnodejs-deploying-with-webpack-to-heroku-build-failed-with-error-code-1%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo