'Is there a way to get npx to create a React app on my computer?
I am totally new to React and Node.js although I have written software in a variety of languages and have created web applications using Cold Fusion. I am using Windows 10 Home Edition 64 bit. I purchased Robin Wieruch's book and followed the instructions to download Node.js, React and Visual Studio Code. When I typed in npx create-react-app hacker, I got errors and tried various fixes from youtube videos. No success. The code is below. Is there a fix or work around?
C:\Users\Warren\Documents\proj>npm uninstall -g create-react-app && npm i -g npm@latest && npm cache clean -f
removed 66 packages in 1.335s
C:\Users\warre\AppData\Roaming\npm\npm -> C:\Users\warre\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\warre\AppData\Roaming\npm\npx -> C:\Users\warre\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
+ [email protected]
added 256 packages from 146 contributors in 13.76s
npm WARN using --force Recommended protections disabled.
C:\Users\Warren\Documents\proj>npx create-react-app hacker
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
(node:11992) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, mkdir 'C:\Users\Warren\Documents\proj\hacker'
at Object.mkdirSync (fs.js:1009:3)
at Object.module.exports.makeDirSync (C:\Users\warre\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\fs-extra\lib\mkdirs\make-dir.js:101:15)
at createApp (C:\Users\warre\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js:255:6)
at C:\Users\warre\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js:226:9
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11992) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Solution 1:[1]
On GitHub, someone solved the same problem you're having,
EPERM: operation not permitted, mkdir ...
by running
npm install -g create-react-app
npx create-react-app
– i.e. installing create-react-app
globally first.
Solution 2:[2]
The fix was almost trivial. I looked at the properties for the project folder in which I wanted to create the new React app. I modified the write permissions for users and the system to enable writing. The npx create-react-app my-app worked without a hitch. Thanks all. I hope this helps someone else. I should have realized that when the MkDir operation failed, it was a read/write issue.
Solution 3:[3]
Yes you can
First create new folder (app name)
```Mkdir appName```
Secondly Cd into your new app
Cd appName
Thirdly run your npx command
npx create-react-app ./
It will work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AKX |
Solution 2 | WarrenH |
Solution 3 | Tech Voltage |