1

I am using reactjs in my application as front end technology. I need to use nodejs as server side programming.

I setup the reactjs application, it has generated project structure and package.json then I installed the express, npm itself has added it into package.json

I created a server directory inside my application for server side code. Here is my directory and package.json

{
  "name": "rock-paper-scissors-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "express": "^4.15.3",
    "react": "^15.6.1",
    "react-dom": "^15.6.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"
  }
}

Project Structure:

enter image description here

So far everything is good. Now I want to generate node-js express application https://github.com/expressjs/express which should not override my existing like package.json

$ express ??

Can anyone help what is the method of it ? or Am I doing something wrong ?

1 Answer 1

1

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.

  1. mern.io This stands for: mongo, express, react and nodejs. This comes with pre-configured React Router, Redux and Server side rendering.
  2. React Starter Kit

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

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

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.