react-scripts: command not found (npm start) - node.js

I've been using create-react-app without issues for some time, but recently, after running it, I cannot start the development server. After running npm start, I get the following error:
sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! js-calculator#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the js-calculator#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Scripts appear to be in the correct location and correctly configured in the package.json file.
Also, npm start throws me the same error if I run it in other react-apps folders that used to work before.
I tried various suggestions I found here on stackoverflow:
installing create-react-app globally;
reinstalling dependencies (npm install);
reinstalling react scripts (npm install react-scripts --save);
updating node and npm;
but none of the above worked.
Any suggestions?
I've also a more detailed .log file, in case anyone wants to have a look at it.

After many tries and more reading of related issues here on SO, I found the cause. One of my react-app parent folders (five levels above) name was "example/example"; naming it to "example-example" solved the problem.

Related

NextJS not running on MacOS even after installing modules

So I've just created a NextJS project using create-next-app which went smoothly as expected. Then ran npm i just to be sure and saw all modules installed into node_modules
When I try to run npm run dev to start my nextjs app. it just says
sh: next: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! test#0.1.0 dev: `next dev`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the test#0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/john.v.n.pakson/.npm/_logs/2022-10-06T08_01_29_725Z-debug.log
It seems like npm is not detecting the node_modules i have installed.
Not sure if this is a mac or a zsh issue.
I'm using node version 12.22.12
Upgraded to 16.17.1 and still see the same error
> test#0.1.0 dev
> next dev
/var/folders/6y/xtlzp4z16dj0stxnqx8znj8w0000gn/T/dev-01c08137.sh: line 1: next: command not found
Okay I figured it out. It was caused by my file path on macos. My project was on a folder called Project/Test which might have confused zsh or mac. This in turn caused npm to not be able to find the correct scripts on my node_modules
When I moved my project to another folder I was already able to run npm run dev properly.
Cheers!

Why has my server stopped working after trying to install SCSS?

Currently, I am following a course in React development. As a part of the course, we have to install SCSS to style an e-commerce app. So far, I have tried avoiding SCSS and reformat the code to CSS. However, since there is no $ SCSS equivalent in CSS, I am forced to install SCSS. Nevertheless, after writing
npm add node-sass
I had to restart my server and I got the error stated at the end. In the course, they mention that there might be some bugs and in that case, we should use the following lines
rm -rf npm.lock
rm -rf node_modules
Despite using these lines, my server still will not start and I am still stuck being unable to proceed since I need SCSS to work, and for that, I need my server to work because I need to restart it to install NCSS. In the following lines, I will leave the error message I get when I try to start my server. npm and node are already installed.
aaronserpilin#Aarons-MacBook-Air crown-clothing % npm start
> crown-clothing#0.1.0 start /Users/aaronserpilin/crown-clothing
> react-scripts start
sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! crown-clothing#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the crown-clothing#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aaronserpilin/.npm/_logs/2021-10-02T13_22_23_006Z-debug.log
aaronserpilin#Aarons-MacBook-Air crown-clothing %
what your node-sass version used?
i used node-sass#4.14.1 and react#17.0.0 is work

Npm Start not running node.js, not running scripts

I am setting up a project with node & express. I am running the same error message.
I've read multiple help articles suggesting to clear the cache and create new .json files. I've also edited the scripts in the package.json file and had no luck clearing the error.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! package#1.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the package#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
Looks like your script is running node ./bin/www so do you have those folders and index.js file inside the directory?
Share your package.json and maybe it will give more info.
I think you have used express generator to generate boiler code, to to test code in this case.
for macos
DEBUG=yourprojectfoldername:* npm start
for windows
set DEBUG=myapp:* & npm start

Even though my PATH points to nodejs, node is not recognized. How do I fix this?

For class we were asked to install Git, Nodejs and VSCode.
After that, we were asked to run npm install -g #angular/cli through gitbash
After waiting a bit, I get an error message:
'node' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#8.3.14 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#8.3.14 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\JumpNShootMan\AppData\Roaming\npm-cache\_logs\2019-10-26T15_48_32_620Z-debug.log
I have tried reinstalling everything and triple checked that the paths were set up correctly. What I don't know is if it's alright for the computer to run some things on Roaming and I don't know if that's my fault. I'm not really good at these things and I'm lost. I thought it would be easy to install :(
Please help
edit: tried reinstalling again, nothing worked. Node as a command is not recognized

react scripts not found

I have a problem running npm start from my newly created project, the thing is the problem doesn't seem to occur outside of this folder (its a git repo, so it needs to be in here). If i create a new project in another folder and run npm start I have no issues at all.
So I recently started working in Ubuntu 18.04LTS, gone through all the setup of installing nodejs and npm.
Currently running versions:
node = 10.16.0
npm = 6.9.2
So I created my app by using npx create-react-app
When i run npm start inside this, it throws me an error:
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! frontend#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the frontend#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
I tried create the app in another folder, testing if i can run npm start (yes) and the move this app to my repo, but then it fails again.
If i understand well what you wrote, "npm start" worked fine when you changed folders. If this is the case, you should know that Node has issues reading the path when some particular characters (like "&") or spaces are in the name of a folder.
Try to change the folder's name.

Resources