Johhan Johhan - 1 year ago 66
Node.js Question

How to run npm start for reactjs even after closing terminal?

I've been following facebook tutorial with reactjs

I installed

npm install -g create-react-app and created the app with it

But now I'm confuse how do I deploy my app to, for example, digital ocean? I know I can use
to run a node server but I don't see how does
npm start
works as it just runs this in the package.json

"name": "hello-world",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.7.0"
"dependencies": {
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"express": "^4.14.0",
"mongoose": "^4.6.8",
"react": "^15.3.2",
"react-dom": "^15.3.2"
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"

"start": "react-scripts start"
what is it actually starting there?

also, it says that to build your app for deployment to use
npm run build
that just gives me a folder named
but I can't find anything to run

Answer Source

I recommend reading the User Guide as it answers many common questions.

npm start starts the development server. It's only useful for development so you should never use it in production. This is printed in its output.

npm run build produces a static build folder with HTML, CSS, and JS files. You don't need Node to run it. It is static. To serve it, you would need to use any static file server. You can do this with Node, Python, Nginx, or any file server that can serve static files. This should also be printed in the command's output.

The deployment instructions vary depending on your hosting provider but basically you need to serve the build output from the server root, and you're set. If you use client-side routing you'll also want to configure your web server to serve index.html as a fallback for any path.

The user guide includes specific deployment instructions for different providers so check it out.