0

It works when i run npm start, but in heroku i cant do it works,

2017-06-28T17:18:54.167693+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-06-28T17:18:54.167918+00:00 app[web.1]: npm ERR! errno ENOENT
2017-06-28T17:18:54.168018+00:00 app[web.1]: npm ERR! syscall spawn
2017-06-28T17:18:54.168132+00:00 app[web.1]: npm ERR! [email protected] start: `react-scripts start`
2017-06-28T17:18:54.168203+00:00 app[web.1]: npm ERR! spawn ENOENT
2017-06-28T17:18:54.168300+00:00 app[web.1]: npm ERR! 
2017-06-28T17:18:54.168387+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2017-06-28T17:18:54.169487+00:00 app[web.1]: 
2017-06-28T17:18:54.168480+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-06-28T17:18:54.169649+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-06-28T17:18:54.169703+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2017-06-28T17_18_54_163Z-debug.log

my package.json, i saw on internet that maybe here is the problem

<!-- language: lang-js -->

    {
      "name": "juego-cartas-reactjs",
      "version": "0.1.0",
      "main":"src/index.js",
      "dependencies": {
        "font-awesome": "^4.7.0",
        "lodash.shuffle": "^4.2.0",
        "react": "^15.6.1",
        "react-dom": "^15.6.1",
        "react-flipcard": "^0.2.1"
      },
      "devDependencies": {
        "react-scripts": "1.0.7"
      },

      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      }
    }

I dont know what else to do, if anyone know something about this, help

6
  • Did you run a npm install on the server to make sure that react-scripts exists? Looks like that's where it's failing. Commented Jun 28, 2017 at 17:32
  • you mean in the console of my heroku project app? Commented Jun 28, 2017 at 17:42
  • Yep exactly! Check out their docs for more help. Commented Jun 28, 2017 at 17:45
  • i think that is not the problem, because i run npm start in my app, and it works properly Commented Jun 28, 2017 at 17:48
  • Yes because you have all of your dependencies installed locally. Do this, go into your app and delete the node_modules folder. Then run npm start and you should get the same error. Then, run npm install and then npm start and it should start working again. Wherever the app is running, the dependencies need to be downloaded and installed. Commented Jun 28, 2017 at 17:50

2 Answers 2

4

npm start is only for local development. You shouldn't be using it on Heroku.

To deploy a Create React App project to Heroku follow Heroku's official guide to it.

cd my-app
git init
heroku create -b https://github.com/mars/create-react-app-buildpack.git
git add .
git commit -m "react-create-app on Heroku"
git push heroku master
heroku open

This article is linked from Deployment section of the User Guide that ships with your created app. I recommend searching for possible answers there.

Sign up to request clarification or add additional context in comments.

1 Comment

this actually doesnt work for me... the app still crashing when i try tu run it in heroku...
3

I've uploaded a create-react-app project successfully on heroku and I didn't use the create-react-app buildpack. Here is my setup:

package.json

//.. rest of package.json

"dependencies": {
  "express": "^4.14.0",
  //.. rest of dependencies 
},

// need to define engines for heroku
"engines": {
  "node": "6.9.1",
  "npm": "3.10.8"
},
"scripts": {
  "start": "node server.js #Production only!",
  "postinstall": "npm run build",
  "dev": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test --env=jsdom",
  "eject": "react-scripts eject"
},

Then in the root directory of the project, I created a server.js, which is just a pretty basic express app. Note that it uses the build folder and not the src folder.

const express = require('express');
const path = require('path');

const app = express();
const port = process.env.PORT || 3000;

app.use(express.static(path.resolve(__dirname, 'build')));

app.get('*', (req, res) => {
  res.sendFile(path.resolve(__dirname, 'build', 'index.html'));
});

app.listen(port, () => {
  console.info(`Server listening on port ${port}`);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.