I am currently trying to use create-react-app which uses three different packages: react, react-scripts and react-dom. I have installed create-react-app and then when I change into the directory and hit npm start I get a react-scripts: command not found. I've ran into a lot of problems with this. I can see react-scripts is in my node_modules folder but I keep getting command not found when trying to run npm start. I tried to delete and re-install all of my node_modules but it didn't work. Anyone else having this issue?
✘ ✝ Node/toDoApp/my-test master± npm start
> my-test#0.1.0 start /Users/jzilch/Desktop/Web
Projects/Node:Express/Node/toDoApp/my-test
> react-scripts start
sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-test#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-test#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
Firstly Delete package-lock.json file in your project folder.
And then install dependencies again by npm install. That should solve this issue.
Delete the /node_modules directory and the package-lock.json file using the rm command:
rm -rf node_modules
rm -rf package-lock.json
Install react-scripts using the following command:
npm install react-scripts
Install the dependencies using the following command:
npm install
Start the local server by running the following command:
npm run start
Note: If you are a Linux user then don't forget to add the sudo command before npm.
This usually happens because of a bad npm packages installation (using npm and yarn at the same time?). It can be desperating, but if you try these steps, it should work.
1st solution:
Remove node_modules folder. At the project's root folder, run
> yarn
> yarn run start
2nd solution:
At the project's root folder, run
> yarn upgrade
> yarn
> yarn run start
Next time you want to add a dependency using create-react-app, I recommend you to use 'yarn add' instead of 'npm install'.
(Source: https://github.com/facebook/create-react-app/issues/1155)
I use this in a dockerizer enviroment.
I already install locally in node_modules using package.json.
so, I added this:
RUN npm install -g react-scripts
RUN npm install
That solved my confusing issue
One option is to install the react-scripts package globally using the -g flag. This will make the command available to node, regardless of the working directory.
This command will install react-scripts globally:
npm install -g react-scripts
As I was using yarn, I had to run yarn add react-scripts.
I had this problem for ages and I eventually found my solution by sheer chance.
Turns out, you can't have spaces in any folder names.
e.g.
~/projects/tutorial/ReactJS/JavaScript Framework: ReactJS/app-name
won't work because JavaScript Framework: ReactJS contains spaces.
In general, it's probably not great practice to be using spaces in folder/file names anyway but I hope this saves someone at least 4 hours of trial and error.
I would recommend removing the : from your folder names too! (just to be safe)
i too faced this problem once .to solve this ,delete your
node_modules
yarn.lock
manifest_lock.json
it works .
I fixed it by changing folder name in my local system, from
new/landing
to
new_landing
However, the git branch name remains like "new/landing". This was the case with my MAC system.
For me, I deleted the project and initialized another one with the npm create-react-app <Folder Name> script. Instead of create-react-app <Folder Name>.
It worked for me.
Related
I have tried these two commands and am getting the same error.
npm clean cache --force
npx create-react-app client -timeout=120000
$ npx create-react-app client -timeout=120000
npm WARN exec The following package was not found and will be installed: create-react-app
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Creating a new React app in C:\web_dev\MERN\projects\booking-app\client.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network request to https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz failed, reason: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\web_dev\MERN\projects\booking-app\tmpnodejsnpm-cache\_logs\2021-12-29T13_37_03_989Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting client/ from C:\web_dev\MERN\projects\booking-app
Done.
I have just faced the same issue when upgrading an old project. What solved, in my case was:
If you use yarn:
yarn global remove create-react-app
yarn cache clean
If you use npm:
npm remove create-react-app
npx clear-npx-cache
Also make sure there is no folder in the directory where you will created the new React project because you can get another warning similar to:
The directory . contains files that could conflict:
<the file(s) name here>/
Either try using a new directory name, or remove the files listed above.
After that, npx create-react-app . ran smoothly.
Those steps described above solved the following subsequent warnings (versions may vary).:
Global warning
You are running "create-react-app" 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
tar warning
tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Even I was getting the same error and then saw your question I closed all the task and run this command "npx create-react-app my-app" again it got solved!
I had the same problem so I uninstalled it globally then reinstall:-
npm uninstall -g create-react-app
npm uninstall create-react-app
Then I used npx:-
npx create-react-app project-app
Tell me if this works for you
Try this:
npm install -g npm#latest
npm install node
npm install -g yarn
yarn cache clean
npx create-react-app my-app
I had the same error sometime ago,
just make sure you don't have any space between the name of your directories folders
like Desktop/react project/my-react-app ...this is wrong
try this
Desktop/reactproject/my-react-app ... correction
I encountered the following error when I tried to install some new packages using npm install. It happened when I did npm install a-new-package --save and then delete package-lock.json file afterwards to refresh everything.
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/plugin-proposal-decorators
npm ERR! dest /Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/plugin-proposal-decorators' -> '/Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/memphismeng/.npm/_logs/2021-06-15T18_07_01_162Z-debug.log
What went wrong? I also tried npm audit fix --legacy-peer-deps but it didn't work.
May be deleting node_modules folder and package-lock.json file and then reinstalling npm would resolve your issue.
So, consider the following commands to apply the above operations:
npm remove node_modules
npm remove package-lock.json
npm install
Obviously, the deleting of package.json is working but this is not always the desired solution. Sometimes you want to run:
npm i --package-lock-only //to update package.lock.json
npm audit fix
and then:
npm i
And this should be the first try but, I don't know why it didn't work in my case, which is in react native scenario. It seems like the error "npm install error ENOTEMPTY" is happening when the npm try to write to a folder that is not empty and in this case to "node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw". If you run:
rm -rf node_modules/#babel/.plugin-proposal-decorators-ysLLPQFw
And then:
npm i
It should work this time. It should be a cleanup process of react-native though, and when working with web starter kit like CRA it never happened to me before.
I had the same problem while having a slow and unreliable Internet connection. I created this script that can be run with bash that fixes all of the interrupted installs:
#!/bin/bash
set -e
while true; do
log="$HOME/.npm/_logs/`ls $HOME/.npm/_logs/ | tail -n 1`"
echo "log: $log"
for path in `cat "$log" | grep 'ENOTEMPTY' | grep -oE "[^']+node_modules[^']+"`; do
echo "removing $path"
rm -rf "$path"
done
if npm install; then
break
fi
done
Basically, I use the approach from https://stackoverflow.com/a/69668434/1320237 but I just had too much do deal with manually.
Note: While it looks to me like it has a O(n * n) run time, it might have a O(n) download time for n = number of packages. So it is useful for slow Internet. You might be faster to just delete the node_modules directory if your Internet connection is fast.
I had a quite similar issue while working with npm.
What worked like a charm for me was updating my packages & dependencies for the project, specifically react-scripts.
Check what are your outdated packages with:
npm outdated
Or, follow the code snippets of this guy in medium, that automates the task of check and update your packages one by one.
I have gone through all the questions regarding this issue but I cannot seem to find anything that works.
I am getting this error :-
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.11.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I have tried to remove the node_modules and npm install again. I also tried to remove the node-sass folder in the node_modules and npm install -g node-sass#latest did not work too. I also tried
npm install -g node --unsafe-perm=true --allow-root
and
npm uninstall node-sass
npm cache clean --force
npm install -g node-sass#latest
but nothing seems to be working at all. Is there someone who can shed some light on this please?
Thanks for your time
Unless you're working on some sort of shared project that has strict requirements you can do the following to overcome the issue:
1.) Delete your package.lock file - which indicates the versions to be locked at.
2.) Delete your node_modules folder which contains all the original installations and C++ binary compilations.
3.) Then npm install it all back and npm rebuild for good measure.
It looks like this is documented on the Node-Sass page in NPM. Upgrade to Node-Sass v 4.12.0 and it will work with Node 12.
try this command it should work successfully
sudo npm install -g --unsafe-perm node-sass
it work for me
Following steps worked for me.
Remove node_modules folder.
Remove package-lock.json file.
Run sudo npm install -g --unsafe-perm node-sass
Run npm install without sudo command.
After battling with this issue for a considerable amount of hours, I downgraded from the Current version of Node (12.8.0) to the LTS (10.16.2) and it finally worked. So if you are having issues like mine, maybe try to downgrade the node version and it can help you
This is because of your incompatible node version with the node-sass module
by the way node-sass is deprecated.
check this link and select the best version with your node installed
https://www.npmjs.com/package/node-sass
just use following command.
npm update
I had created reactjs project first I had installed globally create react app
npm install -g create-react-app
next, I try to project creation. am using this command
create-react-app react-firebase
while installing i had faced npm ERR! 404 Not Found: react-dev-utils#^5.0.2
error:
npm ERR! code E404
npm ERR! 404 Not Found: react-dev-utils#^5.0.2
How to fix it...
i tried this yarn add -g react-dev-utils#https://registry.npmjs.org/react-dev-utils/react-dev-utils-5.0.2.tgz (remove the "/-/" from the URL) and then run create-react-app my-app and it worked.
or if using npm try:
npm install -g react-dev-utils#https://registry.npmjs.org/react-dev-utils/react-dev-utils-5.0.2.tgz
The problem is npm is not able to find react-dev-utils in the registry server.
you can try different registries as mentioned here
Can't install any packages in Node.js using "npm install"
then you can solve this installing that package
npm install react-dev-utils#^5.0.2 -g
Something has changed in the registries. Explicitly adding the package didn't work for me, but flushing the lock files to remove reference to the old registry path did:
Yarn:
Delete yarn.lock
Run yarn
NPM:
Delete package-lock.json
Run npm install
I have a Docker container that fails to do a npm install for a react.js app that is cloned in the container when it is built. Would anybody know how to resolve the issue?
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! myrideweb#0.1.0 build: `react-scripts build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the myrideweb#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-06-19T04_00_09_065Z-debug.log
Dockerfile:
FROM ubuntu
Run apt-get update
Run apt-get install curl -y
Run curl -sL https://deb.nodesource.com/setup_10.x
Run apt-get install -y nodejs
Run apt-get install -y git
Run apt-get install npm -y
Run apt-get update -y
Run git clone https://github.com/sdrafahl/TerraWeb.git
WORKDIR /TerraWeb
Run npm install -g --save npm#latest
...
I have a similar issue and I managed to work around by changing:
"start: "react-scripts start"
to:
"start: "./node_modules/.bin/react-scripts start"
in the scripts section package.json.
I use the classic node base image but it should work more or less the same.
And I am still investigating why NPM is not able to resolve react-scripts when running inside Docker, any further help is very welcome :-)
This happened to me when 'react-scripts' was listed under the 'devDependencies' in the package.json file. Moving it to the "dependencies" section solved the issue.
Deleting package-lock.json and re-installing packages with npm install before building the container solved the issue for me.
I had this issue with react-scripts#4.0.1. I uninstalled and re-installed and that seemed to do the trick.
npm uninstall react-scripts
npm install -D react-scripts
Ok, I just managed to solve this problem in few simple steps, and i hope these instructions will help you too.
I run a docker with Ubuntu on Windows 10, and I share the node_modules folder by volume if this sounds familiar to you, so I believe this solution will help you.
Accidentally I installed the node modules from my Windows user, and that what cause the whole permissions problems.
So what I did is to delete the node_modules directory.
Then I installed the node modules from the Ubuntu Terminal, run npm install.
You may have to install npm on your Ubuntu, I downloaded the nvm installation file with curl with those instructions, How to install node on WSL for Linux, and then you may run npm install and then the react script will be able to run.
After you run npm install from Ubuntu, build and run your dockers.
I had this same problem recently and I was able to solve it, however, I don't like the solution very much but I think it's OK since it should run in Docker or in you local machine. That being said, my suggestion is to update the package.json with the following:
{
"scripts": {
"start": "$(npm bin)/react-scripts start",
}
}
npm-bin docs