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

Deploy to Heroku fails with npm ERR! missing script: start #122

Closed
mariotatis opened this issue Jul 23, 2021 · 1 comment
Closed

Deploy to Heroku fails with npm ERR! missing script: start #122

mariotatis opened this issue Jul 23, 2021 · 1 comment

Comments

@mariotatis
Copy link

Hi Guys,
I've tried to deploy the json-graphql-server to Heroku, but, I'm still not able to do do.

I'm getting npm ERR! missing script: start

Can you please guide me on the correct way to configure the Heroku Procfile or package.json to properly getting the server running on Heroku?

Thanks a lot.

@mariotatis
Copy link
Author

mariotatis commented Jul 23, 2021

Guys, I managed to solve the issues to deploy successfully to Heroku

1- Add a Procfile

Add a file to the project root folder Procfile with the following:

web: npm start

2- Add start script in package.json

    ....
       "scripts": {
        ...
        "start": "bin/json-graphql-server.js db.js"
    },
    ...

3- Update bin/json-graphql-server.js

Removed the Port and Host definitions
Update the app.listen

#!/usr/bin/env node
require('reify');
var path = require('path');
var express = require('express');
var JsonGraphqlServer = require('../lib/json-graphql-server.node.min').default;

var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json';
var data = require(path.join(process.cwd(), dataFilePath));
var app = express();

app.set('port', (process.env.PORT || 3000));
app.use('/', JsonGraphqlServer(data));
app.listen(app.get('port'));

Now, server runs in Heroku with no issues.


It will continue to work in your local env in your http://localhost:3000/

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