Search code examples
reactjsexpressproxyvite

How to execute react/vite/nodejs/express app simultaneously?


I am new to React and JavaScript. I am having troubles linking my client and backend together. I try to start frontend and backend simultaneously to be able to send requests to backend and fetch data into my frontend. I followed this tutorial: https://levelup.gitconnected.com/how-to-simultaneously-run-the-client-and-server-of-your-full-stack-app-in-one-folder-ef5a988d56d7

After i try to run npm run dev i am getting following error:

PS C:\Users\sebas\Downloads\LiveFanaticSS> npm run dev
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
> [email protected] dev
> concurrently "npm run server" "npm run client"
[0] npmnpm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
[0]  WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.      
[1] 
[1] > [email protected] client
[1] > npm start --prefix client 
[1] 
[0] 
[0] > [email protected] server
[0] > npm start --prefix server 
[0] 
[0] npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
[1] npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
[0] 
[0] > [email protected] start
[0] > nodemon index.js  
[0] 
[1] npm ERR! Missing script: "start"
npm ERR! 
[1] npm ERR! Did you mean one of these?
[1] npm ERR!     npm star # Mark your favorite packages   
npm ERR!     npm stars # View packages marked as favorites
[1] npm ERR! 
[1] npm ERR! To see a list of scripts, run:
npm ERR!   npm run
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     C:\Users\sebas\AppData\Local\npm-cache\_logs\2023-01-27T18_44_00_542Z-debug-0.log
[1] npm run client exited with code 1
[0] [nodemon] 2.0.20
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching path(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node index.js`
[0] http://localhost:3333
[0] server running on port 3333

How can i fix it?


Solution

  • Okay i solved my problem by adding "start": "vite" into my package.json file in Client! I was adding it in wrong places before.