Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the Heroku hosting working #42

Closed
RhodesPeter opened this issue Nov 22, 2016 · 8 comments
Closed

Get the Heroku hosting working #42

RhodesPeter opened this issue Nov 22, 2016 · 8 comments

Comments

@RhodesPeter
Copy link
Member

Heroku was working when the files were uploaded via git but not when directly from our Github. These are the error messages:

screen shot 2016-11-22 at 20 52 50

@RhodesPeter
Copy link
Member Author

This was the error I was getting earlier:

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

I am no longer getting this error, so I guess this is no longer a problem. I don't really know what it means anyway. The error disappeared when I replaced the consts and lets with var.

@RhodesPeter
Copy link
Member Author

RhodesPeter commented Nov 22, 2016

Update.

The package.json file main was changed from index.js to server.js which for some reason heroku was not happy about. When I change it back I get the same error about the ES6 features.

@RhodesPeter
Copy link
Member Author

Fixed.

I changed the consts and lets back to vars and it is now working and hosted on Heroku here. If we have time it would be good to work out which bits of ES6 we can use and which we can't. Obviously the 'Block-scoped declarations' but I will leave this until tomorrow.

@RhodesPeter
Copy link
Member Author

If we simply needed to add strict mode to all of our js files I will do one of those facepalms people do.

@RhodesPeter
Copy link
Member Author

This is fixed now with commit d904bd9.

The key was to add this code to package.json. This asks Heroku to install and use the latest version of Node which will be happy with ES6 features.

"engines": {
    "node": "6.9.1"
}

@RhodesPeter
Copy link
Member Author

So for next time:

  1. Add this to package.json:
"engines": {
    "node": "6.9.1"
}
  1. "main" in package.json should be "index.js" rather than "server.js"
  2. procfile isn't needed (and throws an error), instead set up like this in package.json:
"start": "node src/server.js"

@RhodesPeter
Copy link
Member Author

RhodesPeter commented Nov 23, 2016

Also!!

server.js should look like this:

server.connection({
  port
});

Previously it looked like this:

server.connection({
    port,
    host: 'localhost'
  });

@RhodesPeter
Copy link
Member Author

Update - 2017! - The whole of the server connection is actually like this:

const port = process.env.PORT || 8000;

server.connection({
  port
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant