React Error: EPERM: operation not permitted - reactjs

I am learning react and trying to create react app from command line in windows 10. But it gives an error in middle of the process. Below is the error log.
My node version is v10.8.0 and npm version is 6.2.0
I am using below command to create the app.
D:\react>create-react-app myappreact
Creating a new React app in D:\react\myappreact.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! path D:\react\myappreact\node_modules\.staging\url-parse-6c16a96d\index.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\react\myappreact\node_modules\.staging\url-parse-6c16a96d\index.js'
npm ERR! { [Error: EPERM: operation not permitted, unlink 'D:\react\myappreact\node_modules\.staging\url-parse-6c16a96d\index.js']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\react\myappreact\node_modules\.staging\url-parse-6c16a96d\index.js'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'D:\\react\\myappreact\\node_modules\\.staging\\url-parse-6c16a96d\\index.js' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, unlink \'D:\\react\\myappreact\\node_modules\\.staging\\url-parse-6c16a96d\\index.js\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'D:\\react\\myappreact\\node_modules\\.staging\\url-parse-6c16a96d\\index.js',
npm ERR! parent: 'myappreact' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

I had exactly the same problem. I simply turned off my Windows Defender Real-time protection and ran the create-react-app command again, then the problem has been solved.

Try deleting all text files on npm-cache logs folder. It worked for me.
C:\Users\yours\AppData\Local\npm-cache\_logs

Related

I am trying to install the node-sass but getting error. How can I fix this

While I am trying to install the node-sass I am facing error during installation process. Could someone tell how can I resolve this.
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\deepe\OneDrive\Documents\Yajnaseni\POC\language\node_modules\node-gyp
npm ERR! dest C:\Users\deepe\OneDrive\Documents\Yajnaseni\POC\language\node_modules\.node-gyp-fscmffkd
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\deepe\OneDrive\Documents\Yajnaseni\POC\language\node_modules\node-gyp' -> 'C:\Users\deepe\OneDrive\Documents\Yajnaseni\POC\language\node_modules\.node-gyp-fscmffkd'
npm ERR! [Error: EPERM: operation not permitted, rename 'C:\Users\deepe\OneDrive\Documents\Yajnaseni\POC\language\node_modules\node-gyp' -> 'C:\Users\deepe\OneDrive\Documents\Yajnaseni\POC\language\node_modules\.node-gyp-fscmffkd'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\Users\\deepe\\OneDrive\\Documents\\Yajnaseni\\POC\\language\\node_modules\\node-gyp',
npm ERR! dest: 'C:\\Users\\deepe\\OneDrive\\Documents\\Yajnaseni\\POC\\language\\node_modules\\.node-gyp-fscmffkd'
npm ERR! }
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\deepe\AppData\Local\npm-cache\_logs\2020-12-07T07_55_05_230Z-debug.log
have you tried restarting your system
you can also try this
navigate to node modules folder and delete .node-sass
after that execute this command
npm cache verify
npm install
Are you sure you are in the project when you are trying to install node-sass?
I am not sure if it is related. I seem to have problem getting node-sass 5.0.0 to run with reactJs, I am using node-sass#4.14.1.
Have you tried install the version 4.14.1.
npm install node-sass#4.14.1
As mentioned by #Maduekwe Pedro restart the system. Remane or delete the .scss file in the editor and then do
npm cache verify
npm i node-sass

How can I solve this new error on the command line?

This error happened when I was creating my react app - I can not solve it.
Reinstalled node and changed directory from drive of windows but nothing changed.
Thanks for your help
C:\Users\Polymer>W:
W:\>cd CMD
W:\CMD>npx create-react-app my-app
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Users\Polymer\AppData\Roaming\npm-cache\_cacache\index-v5\2b\1c
\4ede2f97cfb5e7b1fe999329dd5b5252cac9a58995c5659a37aaf25d18cb
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\Polymer\AppData\R
oaming\npm-cache\_cacache\index-v5\2b\1c\4ede2f97cfb5e7b1fe999329dd5b5252cac9a58
995c5659a37aaf25d18cb'
npm ERR! { [Error: EPERM: operation not permitted, open 'C:\Users\Polymer\AppDa
ta\Roaming\npm-cache\_cacache\index-v5\2b\1c\4ede2f97cfb5e7b1fe999329dd5b5252cac
9a58995c5659a37aaf25d18cb']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, open 'C:\Users\Polymer\AppD
ata\Roaming\npm-cache\_cacache\index-v5\2b\1c\4ede2f97cfb5e7b1fe999329dd5b5252ca
c9a58995c5659a37aaf25d18cb'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path:
npm ERR! 'C:\\Users\\Polymer\\AppData\\Roaming\\npm-cache\\_cacache\\index
-v5\\2b\\1c\\4ede2f97cfb5e7b1fe999329dd5b5252cac9a58995c5659a37aaf25d18cb' },
npm ERR! isOperational: true,
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, open \'C:\\Users\\Polymer\\A
ppData\\Roaming\\npm-cache\\_cacache\\index-v5\\2b\\1c\\4ede2f97cfb5e7b1fe999329
dd5b5252cac9a58995c5659a37aaf25d18cb\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path:
npm ERR! 'C:\\Users\\Polymer\\AppData\\Roaming\\npm-cache\\_cacache\\index-v5
\\2b\\1c\\4ede2f97cfb5e7b1fe999329dd5b5252cac9a58995c5659a37aaf25d18cb' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or ant
ivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check t
he
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Polymer\AppData\Roaming\npm-cache\_logs\2020-07-11T19_05_3
5_466Z-debug.log
Install for create-react-app#latest failed with code 4294963248
W:\CMD>create-react-app my-app
'create-react-app' is not recognized as an internal or external command,
operable program or batch file.
Open the shell with Run as Administrator or grant owner access to those directories.
npm ERR! { [Error: EPERM: operation not permitted, open 'C:\Users\Polymer\AppDa ta\Roaming\npm-cache_cacache\index-v5\2b\1c\4ede2f97cfb5e7b1fe999329dd5b5252cac 9a58995c5659a37aaf25d18cb'], or try running npm ERR! the command again as root/Administrator. .... suggests permission issues
If this doesn't work - another SO thread suggests multiple approaches, report back if you are still facing issues with a -debug.log preferably
npm - EPERM: operation not permitted on Windows

npm install -g create-react-app Giving error -4048 , -4051 on Windows

I have gone through similar questions on SO, but didn't worked any of them.
I have tried clearing cache, re-installing, working as administrator etc. but getting same error
on npm install -g create-react-app or any dependency with npm install
npm -v: 6.14.4
node -v: 12.16.3
Error am Getting:
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\praba\OneDrive\Desktop\croapp\croapp\node_modules\.staging
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\praba\OneDrive\Desktop\croapp\croapp\node_modules\.staging'
npm ERR! [Error: EPERM: operation not permitted, unlink 'C:\Users\praba\OneDrive\Desktop\croapp\croapp\node_modules\.staging'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\praba\\OneDrive\\Desktop\\croapp\\croapp\\node_modules\\.staging'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\praba\AppData\Roaming\npm-cache\_logs\2020-05-11T20_41_47_242Z-debug.log
`npm install --save #testing-library/react#^9.3.2 #testing-library/jest-dom#^4.2.4 #testing-library/user-event#^7.1.2` failed
C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:321
throw er
^
Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\praba\AppData\Roaming\npm-cache\_npx\7480\node_modules\create-react-app\node_modules'
at Object.rmdirSync (fs.js:770:3)
at rmkidsSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:364:25)
at rmdirSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:342:7)
at rimrafSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:312:9)
at C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:350:5
at Array.forEach (<anonymous>)
at rmkidsSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:349:26)
at rmdirSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:342:7)
at rimrafSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:312:9)
at C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:350:5 {
errno: -4051,
syscall: 'rmdir',
code: 'ENOTEMPTY',
path: 'C:\\Users\\praba\\AppData\\Roaming\\npm-cache\\_npx\\7480\\node_modules\\create-react-app\\node_modules'
}
Thank You!
you can create react projects without cli using npx
npx creat-react-app app-name
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
Be sure nothing is currently using the node_module/.staging file.
But definitely use npx creat-react-app app-name instead.
Here is the react documentation on this.
https://reactjs.org/docs/create-a-new-react-app.html#create-react-app

How to fix permission errors with npm

I'm trying to create a new React app but am running into permission errors that I don't understand. I'm pretty new to programming so I don't quite understand what's going on. Below is a copy of my terminal. I am using a Mac with Mojave version 10.14.6. I have Node v10.15.3 installed npm 6.9.0 and npx 6.9.0.
I've had other permission errors before and have used sudo to get around them, but I would really like to know what the root cause of these permission errors is and how to fix it.
Monicas-MacBook-Air:code monica$ npx create-react-app weekly-scheduler
Creating a new React app in /Users/monica/code/weekly-scheduler.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
npm ERR! path
/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4 npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall open npm ERR!
Error: EACCES: permission denied, open
'/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4'
npm ERR! { [Error: EACCES: permission denied, open
'/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4']
npm ERR! cause: npm ERR! { Error: EACCES: permission denied, open
'/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4'
npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR!
syscall: 'open', npm ERR! path: npm ERR!
'/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4'
}, npm ERR! isOperational: true, npm ERR! stack: npm ERR!
'Error: EACCES: permission denied, open
\'/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4\'',
npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall:
'open', npm ERR! path: npm ERR!
'/Users/monica/.npm/_cacache/index-v5/67/c7/8dd80b7495bd43b4dedc63a0cbc936eed1bb997cd36191f55d47f11693a4',
npm ERR! parent: '#babel/plugin-proposal-unicode-property-regex' }
npm ERR! npm ERR! The operation was rejected by your operating
system. npm ERR! It is likely you do not have the permissions to
access this file as the current user npm ERR! npm ERR! If you believe
this might be a permissions issue, please double-check the npm ERR!
permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not
recommended).
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/monica/.npm/_logs/2019-12-06T20_36_41_071Z-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 weekly-scheduler/
from /Users/monica/code Done.

npm WARN deprecated circular-json#0.3.3: CircularJSON is in maintenance only, flatted is its successor

I am totally beginner in React JS. After installing a package named 'Tachyons' with this command npm install --save-dev tachyons#4.10.0 I am keep getting this error while starting the npm with this command npm start in the react project. But the thing is- It was working fine before installing the package. I don't know what's got wrong. Hope someone will help me out. Thanks.
npm WARN deprecated circular-json#0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated kleur#2.0.2: Please upgrade to kleur#3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm WARN rollback Rolling back #types/node#11.9.5 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\User\Desktop\robofriends\node_modules\#types\node'
npm WARN ts-pnp#1.0.1 requires a peer of typescript#* but none is installed. You must install peer dependencies yourself.
npm ERR! path C:\Users\User\Desktop\robofriends\node_modules\#types
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall mkdir
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\User\Desktop\robofriends\node_modules\#types'
npm ERR! { [Error: EPERM: operation not permitted, mkdir 'C:\Users\User\Desktop\robofriends\node_modules\#types']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, mkdir 'C:\Users\User\Desktop\robofriends\node_modules\#types'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path:
npm ERR! 'C:\\Users\\User\\Desktop\\robofriends\\node_modules\\#types' },
npm ERR! stack:
npm ERR! "Error: EPERM: operation not permitted, mkdir 'C:\\Users\\User\\Desktop\\robofriends\\node_modules\\#types'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path:
npm ERR! 'C:\\Users\\User\\Desktop\\robofriends\\node_modules\\#types',
npm ERR! parent: 'robofriends' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-02-24T22_26_47_036Z-debug.log
The log you have is actually quite clear on possible reasons you are getting the error...
The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
Do you have another terminal open?
If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
Run your command prompt as administrator.
Other than the above, the first 4 lines of the log give you warnings, you should always avoid using an old version of packages or packages that are not being actively maintained.

Resources