简体   繁体   中英

How to run node js and react?

My question is simple How to run a server node js and a react app in same time? My package.json

 { "name": "mon-app", "version": "0.1.0", "private": true, "dependencies": { "express": "^4.17.1", "react": "^16.14.0", "react-dom": "^16.14.0", "react-scripts": "0.9.5" }, "devDependencies": { "concurrently": "^2.2.0" }, "scripts": { "start": "concurrently \\"node server.js\\" \\"react-scripts start\\"", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" }

I use concurrently Moreover npm start runs of course the dev server Thanks for your help :)

you can try doing something like this:

 { "name": "mon-app", "version": "0.1.0", "private": true, "dependencies": { "express": "^4.17.1", "react": "^16.14.0", "react-dom": "^16.14.0", "react-scripts": "0.9.5" }, "devDependencies": { "concurrently": "^2.2.0" }, "scripts": { "server": "node server.js", "client": "react-scripts start", "start": "concurrently \\"npm run server\\" \\"npm run client\\"", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" }

does that solve your problem?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM