You may need to install express inside server directory. Go inside server directory by cd server and type express myapp. This will generate a complete separate express app using different package.json file.
note: Expressjs generator must be installed before express myapp command. You can install expressjs generator by npm install -g express-generator
Since this is not a good idea for going full-stack in react. You can consider a couple of starter kits for this task.
- mern.io This stands for: mongo, express, react and nodejs. This comes with pre-configured React Router, Redux and Server side rendering.
- React Starter Kit
Answer from Ejaz Karim on Stack OverflowReact Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)
Videos
What is reactjs-express-generator?
Is reactjs-express-generator popular?
Is reactjs-express-generator safe to use?
hi so basically I have been using express generator to make new express apps. I can make servers and then endpoint routes and then I then render html files for each of the routes visited and i use PUG as the view engine.
app.set("views", path.join(__dirname, "../views"));app.set("view engine", "pug");
Pug is nice but I am trying to figure out how to use react instead of making views for every route. Also as far as styling, using express generator I seem to only be able to edit styles.css to write vanilla css and then I have to serve the static path.
app.use(express.static(path.join(__dirname, "../public")));
In a nutshell, I am just trying to figure out how to use react with nodejs and express. I read a couple of guides so I think I have the directory structure correct (client and server, each with their own node modules), but not sure on how to proceed. any advice? I've attached my repo. thanks.
https://github.com/ForkEyeee/blog-api
» npm install generator-express-react
» npm install generator-react-express-jest
» npm install create-react-express-app