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.
Related
I'm having trouble making a react project for the first time and I'm basically doing npx create-react-app portfolio and this is the log in the terminal
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! Unexpected end of JSON input while parsing near '...w2l6C\nBZrjaE2TabX86o'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ITland\AppData\Roaming\npm-cache\_logs\2020-06-13T14_28_52_450Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts
cra-template has failed.
Deleting generated file... package.json
Deleting portfolio/ from C:\Users\ITland\Desktop\New folder (2)
Has anyone any idea what's causing this error ?
The Log message shown above indicates that the npx command was run inside the folder -
C:\Users\ITland\Desktop\New folder (2)
The npm command can sometimes fail on Windows due to blank spaces or special chars in the folder names.
It is always recommended to avoid spaces and special characters in the folder names where npm is run.
The above problem may be resolved by running the npm / npx command inside
C:\Users\ITland\Desktop\New_folder_2
Try running the below command
npm cache clean --force
Once this is successful, try doing what you are looking for.
Try with the following way:
npm cache clean --force
If you are a windows user, try deleting all files in this folder:
C:\Users{{your-username}}\AppData\Roaming\npm-cache
Then...
npm cache verify
If that doesn't work, try updating to the lastest
npm i npm#latest -g
I have used the command to create react project create-react-app api-tutorial and after installing the project I have used the command npm start. It shows the below error
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-eslint": "10.1.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-eslint was detected higher up in the tree:
D:\react_projects\node_modules\babel-eslint (version: 9.0.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if D:\react_projects\node_modules\babel-eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-api-tutorial#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-api-tutorial#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! C:\Users\My Dell\AppData\Roaming\npm-cache\_logs\2020-05-23T17_04_50_525Z-debug.log
I have deleted the package.lock.json and reinstall the node_modules and in my system updated react-scripts won't work so every time I create the react project I downgrade the version of react-scripts using the command npm install react-scripts#2.1.8 at that time it was working fine. Now it throws the above error.
How can I solve this issue?
Delete package-lock.json or yarn-lock.json and node_modules.
2.Remove babel-eslint from package.json.
Run "npm install" or yarn install..
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
Here is my error page:
There might be a problem with the project dependency tree. It is
likely not a bug in Create React App, but something you need to fix
locally.
The react-scripts package provided by Create React App requires a
dependency:
"webpack": "4.19.1"
Don't try to install it manually: your package manager does it
automatically. However, a different version of webpack was detected
higher up in the tree:
C:\Users\Acer\node_modules\webpack (version: 4.28.3)
Manually installing incompatible versions is known to cause
hard-to-debug issues.
If you would prefer to ignore this check, add
SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will
permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact
order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem. If this has
not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if C:\Users\Acer\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file
in your project. That would permanently disable this preflight check
in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-)
We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! first-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the first-app#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! C:\Users\Acer\AppData\Roaming\npm-cache\_logs\2019-01-03T12_30_23_160Z-debug.log
I've applied all steps but, npm start command still doesn't work.
What should I do?
I got the solution! Focus on the point 6: it asks to delete node_modules folder outside your project directory.
So, I deleted my C:\Users\Acer\node_modules folder and npm start worked for me !!
It is due to the node module dependency conflict.
Delete the node_modules folder from C:\Users\Acer directory. It will resolve the issue.
I tested many ways including delete the node_modules folder but it didn't work , perhaps the best one is to delete the current version of node.js and reinstall it..it answered for me ,i hope it works for you too.
I solved this problem by switching from npm to yarn
Just delete the node_moduelsfolder and the package-lock.json file (not the package.json file). After that just try yarn to install all the packages and here you go.
installation for yarn:
https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable
In your case, C:\Users\ Delete any node_modules folders outside its parent projects folder in the directory folder. Worked for me.
must have to follow all these steps :
curl -sL https://deb.nodesource.com/setup_13.x -o nodesource_setup.sh #installation purpose.
sudo bash nodesource_setup.sh
sudo apt-get install nodejs -y
sudo apt update
sudo apt-get update
npm install -g create-react-app
create-react-app --version
create-react-app hello-react
happy coding!
I've created a .env file and then I added this command==> SKIP_PREFLIGHT_CHECK=true
to the .env file! It works for me!
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.