Prabhat Singh
Prabhat Singh

Reputation: 1555

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!

Upvotes: 0

Views: 1522

Answers (2)

Schnapple
Schnapple

Reputation: 11

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

Upvotes: 0

Anwar Gul
Anwar Gul

Reputation: 683

you can create react projects without cli using npx

npx creat-react-app app-name

Upvotes: 1

Related Questions