In package.json file I have these scripts:
"scripts": {
"server": "json-server --watch db.json --port 5000",
"client": "npm start --prefix client",
"client-build": "npm run-script build --prefix client",
"chat": "nodemon index.js",
"dev": "concurrently "npm run server" "npm run client"",
"build": "concurrently "npm run server" "npm run client-build" "npm run client""
},
And I use the "npm run dev" command to run server and client at the same time.
The server runs, but an error occurs with the client:
react-scripts start
[1]
[1] node:internal/modules/cjs/loader:1051
[1] throw err;
[1] ^
[1]
[1] Error: Cannot find module 'C:UsersehsanDesktopPDEITaghvimsogo_react_20231127clientnode_modulesreact-scriptsbinreact-scripts.js'
[1] at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
[1] at Module._load (node:internal/modules/cjs/loader:901:27)
[1] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
[1] at node:internal/main/run_main_module:23:47 {
[1] code: 'MODULE_NOT_FOUND',
[1] requireStack: []
[1] }
[1]
[1] Node.js v20.9.0
I cleared the npm cache, deleted and reinstalled the node_modules folder, even installed the react-scripts package separately, but none of it worked.
2
Answers
how about
npm i
again before check thereact-scripts
🙂There is several solution to start your application.
npm run build
first, and donpm run start
npm i react-scripts
I
in your project path into something different.