Since this project will hold both the client application and the server application there will be node modules in two different places. First run npm install
from the root. After this you will run npm run-script install-all
from the root. From now on run this command anytime you want to install all modules again. This is a script we have defined in package.json .
This app can be deployed directly to heroku since there is a script defined in package.json which will automatically handle building and deploying the app. For more information on deploying to heroku reference the extra resources at the bottom of this file.
client
- Holds the client applicationpublic
- This holds all of our static filessrc
assets
- This folder holds assets such as images, docs, and fontscomponents
- This folder holds all of the different components that will make up our viewsviews
- These represent a unique page on the website i.e. Home or About. These are still normal react components.App.js
- This is what renders all of our browser routes and different viewsindex.js
- This is what renders the react app by rendering App.js, should not changepackage.json
- Defines npm behaviors and packages for the clientserver
- Holds the server applicationconfig
- This holds our configuration files, like mongoDB uricontrollers
- These hold all of the callback functions that each route will callmodels
- This holds all of our data modelsroutes
- This holds all of our HTTP to URL path associations for each unique urltests
- This holds all of our server tests that we have definedserver.js
- Defines npm behaviors and packages for the clientpackage.json
- Defines npm behaviors like the scripts defined in the next section of the README.gitignore
- Tells git which files to ignoreREADME
- This file!In the project directory, you can run:
npm run-script dev
Runs both the client app and the server app in development mode.
Open http://localhost:3000 to view the client in the browser.
npm run-script client
Runs just the client app in development mode.
Open http://localhost:3000 to view the client in the browser.
npm run-script server
Runs just the server in development mode.
npm run build
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
If deploying to heroku this does not need to be run since it is handled by the heroku-postbuild script
See the section about deployment for more information.
You can learn more in the Create React App documentation.
To learn how to setup a local MongoDB instance for testing, check out how to Connect to MongoDB.
To learn how to deploy a full-stack web app to heroku, check out this great guide.
To learn React, check out the React documentation.
npm run build
fails to minifyThis section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify