Create a React app with express, 'react-scripts' error - node.js

I have been following this webpage: https://medium.com/walmartglobaltech/creating-react-redux-express-full-stack-application-part-i-82959d847802
So the first time I ran into some issues so I thought it would be best to start from scratch.The first time I kept getting errors about 'react-scripts' is not recognized. I tried 'npm install react-scripts --save' but that didn't work so I gave up and deleted that project.
But when I made the new one it highlighted a bunch of stuff as wrong. And when I got to 'npm start' it keeps saying, 'react-scripts' is not recognized as an internal or external command. My friend did this and she didn't run into this error. I am new to Node.js anything would be helpful!
things that I've tried that didn't work:
npm install -f
rm -rf node_modules && npm install
npm install --save react-scripts
npm cache clean --force
npm rebuild
npm install
I created a new workspace and it inherited the error- is there a way to delete it all and try again?
-Please help

You can try using yarn. There have been some who solved it this way. I hope you can solve your problem.
yarn add react-scripts

So there were two issues: first my directory needed to be updated and I didn't have the node_modules in my client folder - hope this helps anyone else!

I had similar problem, but I restarted the system and it worked. Don't know exactly what was causing this issue might be a cache issue.

Related

react app is successfully created, but npm start throws an error

I installed the latest nodejs 19.2.0 on my windows 11 OS rather than the recommended for most users 18.12.1
npx create-react-app my-first-app works just fine, it creates all the files and folders without any errors, shows happy hacking message as well, recommends to use npm start command. I go inside my-first-app folder, go npm start and I get a module not found error...like this picture
Error Message Screenshot
In youtube tutorials, there is no any error in their pc. npm start runs just as easily as npx create-react-app <anyappname>.
F:\Tutorial & Practice\Frontend development\React Projects\my-first-app. With this path to your project, I can see there is an & symbol in the Tutorial & Practice directory. Sometimes that might cause error. Try renaming the directory without any symbols or even spaces, just to be sure. Then run npm start. And if that still doesn't work delete the node_modules folder and then npm install again and see if that works.
Try this first:
npm install react-scripts
If the error wasn't solved, then try this:
rm -rf node_modules
npm cache clean -f
npm install
npm install react-scripts

I tried doing "npm install -g expo-cli" upon which I got a bunch of vulnerabilities. On "npm audit fix" i got the following more errors

So, I've been working in node.js and react native before in Windows 10 without any issues. But ever since I started using this new laptop, with windows 11 in it, I get these annoying errors.
Doing npm install -g npm#8.3.1 gave me the following result
so I did npm audit fix as suggested, on which I was greeted with this:
and so I did npm i --package-lock-only, again, as suggested. Which got me:
IDK what I'm doing wrong. I don't know how it'll affect me. Can someone help me understand this? Thanks!
You can see from the path in your final screenshot that npm is trying to edit your package-lock.json file in the C:\WINDOWS\System32 directory and does not have permission to do that.
You can refer to this answer on how to update your npm configuration to use a folder that you do have permissions to write to.
You have no problem executing React-native even if you do not perform the npm audit fix command
Also, you are not in the right position to do the command. The command must be executed in your project folder.

I can't create new app with create-react-app

I can't fix it no matter what. I have reinstalled node.js probably 8 times. When I google, everyone says run this command npm uninstall -g create-react-app. It didn't get fixed tho. It gives the same problem again and again. I tried npm audit fix --force and every one time it just finds more than 100 vulnerabilities and fixes them again (decreases to 0). I don't know what to do.
I fixed it. After trying many techniques, I somehow got it.
npx --ignore-existing create-react-app
npx create-react-app#latest
That worked for me:
npm uninstall create-react-app
npm update

Unable to find expo in this project - have you run yarn / npm install yet? Npm has been installed, expo directory exists

My Expo project is pretty much 9999999% errors thus far, and it finally reached its climax when it decided to throw an error I've never heard of at me:
module not found: can't resolve '../utilities/platform'
I've never seen this, and I was explicitly working in an isolated styling file when it occurred. I deleted the file and the error persisted. Seeing that it was in node_modules, I figured that deleting node_modules would be helpful. It wasn't. I deleted the node_modules and tried to run npm i --save afterwards but it kept erroring out. I restarted my computer, deleted the new node_modules, and tried to run npm i --save yet again. This time I was greeted with this:
read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json
was generated for lockfileVersion#2. I'll try to do my best with it!
npm ERR! Maximum call stack size exceeded
Now, I have a half(ish) completed node_modules, and whenever I try to run expo start, which I have about 700000000 times before this, it tells me this...
Unable to find expo in this project - have you run yarn / npm install yet?
Which, yes stupid I have my expo set up, and yes AGAIN, I just ran npm install about twenty-two times. So I have absolutely no idea what happened, why it happened, or how to fix whatever happened. If you can help me I will award you my first born but fair warning that might take another 20 years
Try to remove all react-native data folders from "%appdata%\Temp" and execute following commands:
cd android (if any)
gradlew clean
cd.. and remove the node_modules folder
npm cache clean --force
npm install
npm start -- --reset-cache

npm ERR! Unexpected end of JSON input while parsing near '

So this error randomly popped up while I was working on my project:
I've searched online and most of the answers ask to run npm cache clean --force.
This did not work for me :(
I've also tried to reinstall npm but still get the same error.
Here is the error-log:
I've been stuck on this for a while hoping someone can help me out :/
You should try to reinstall entirely nodejs from your computer. This could solve the problem.
sudo apt-get remove nodejs
sudo apt-get install nodejs
You can try "yarn" instead of npm.
Installation (If you are using Mac):
brew install yarn
Or check here
https://classic.yarnpkg.com/en/docs/install/
Then just run (Works like "npm install")
yarn
try npm cache clean --force, fixed the issue for me.
ref: npm-err-unexpected-end-of-json-input-while-parsing-near-743
For my Vue.js project this problem was solved by first deleting the package-lock.json file and then running npm install
Comment from #user2864740 helped point me in this direction, thank you!

Resources