Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while trying to run npx create-react-app in WSL

I am trying to test that npx create-react-app is working. It feels like I have tried everything under the sun and still cannot get it to work. I think it has something do with pathing but I am not exactly sure, and a little bit out of my depth here.

'\\wsl.localhost\Ubuntu-22.04\home\pat\sei\testing'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
node:fs:1395
  handleErrorFromBinding(ctx);
  ^

Error: EPERM: operation not permitted, mkdir 'my-app'
    at Object.mkdirSync (node:fs:1395:3)
    at module.exports.makeDirSync (C:\Users\Patrick\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\fs-extra\lib\mkdirs\make-dir.js:23:13)
    at createApp (C:\Users\Patrick\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js:257:6)
    at C:\Users\Patrick\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js:223:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -4048,
  syscall: 'mkdir',
  code: 'EPERM',
  path: 'my-app'
}

Node.js v18.12.1

I tried to run npx create-react-app my-app. I at first I got an error with node being out of date. So I updated it. That update broke my path again, and so I uninstalled node, then reinstalled it. I then tried it again and it said that the script installed successfully. But when I go to actually use it, I get the above error message.

Update

I did a little more "experimenting" and ran this: npx create-read-app ./ and go this error

'\\wsl.localhost\Ubuntu-22.04\home\pat\sei\testing'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Cannot create a project named "Windows" because of npm naming restrictions:

  * name can no longer contain capital letters

Please choose a different project name.

still lost to be honest

like image 743
Patrick Mangan Avatar asked Oct 29 '25 01:10

Patrick Mangan


1 Answers

I believe the issue is caused by npm from your windows trying to create the folder in your WSL environment which is not allowed.

You can test this by running: which npm

If the output is someting like: /mnt/c/Program Files/nodejs//npm

it means that npm is being mounted from your Windows environment into your WSL.

So try installing npm directly on WSL using: sudo apt install npm

Then try which npm again and it should say /usr/bin/npm

Finally restart your WSL terminal and you should be good to go!

like image 134
Nick Avatar answered Oct 30 '25 15:10

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!