The commands that I entered are
npx create-react-app p1
cd p1
npm start
and the error that I encountered is
Compiled with problems:
ERROR in ./src/logo.svg
Module build failed (from ./node_modules/#svgr/webpack/lib/index.js):
Error: EACCES: permission denied, open '/Users/rudra/.config/svgrrc'
I tried using the sudo before the command but it still didn't work. Is there a problem with npm package, should I try reinstalling it?
The problem is the file .config in your MAC
press> shift + cmd + g
search /Users/rudra/
unhide the file .config pressing cmd + shift + .
rename the file to "config" without dot
create a new file with this name ".config"
and restart your project npm start ;)
I have installing react app using this command
$ npx create-react-app my-app
Then I got Error like this:
Error: EPERM: operation not permitted, mkdir 'C:\Users\Aniket'
command not found: create-react-app
I have seen some online resources they are saying I have to remove space from my Windows Username, isn't there any other way of make this work?
Make sure you've node>=8.10 and npm>=5.6 already installed
Try installing it globally first, using the command
npm install -g create-react-app
And then, you can create your app using the command,
npx create-react-app <Name of your app>
Hope this helps :)
Edit: Above solution might work but it's not recommended way of solving this issue. Please refer https://create-react-app.dev/docs/getting-started
I referred the solution given at bottom and some other posts to use below command:
npm config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global
The easiest way for me is:
mkdir C:\cache
npm config set cache "C:\\cache"
And then run the command again.
Go to c:/users open command prompt and run dir /x check shorter name you found with dir/x as shown in image and run npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global
In my case it's CYBERC~1.
this works fine in my case.
(This is on a Mac by the way. It seems cp -r on a Mac is "historical" and should be replaced by cp -R).
I tried the following:
mkdir TryContext
cd TryContext
npx create-react-app my-app
cd my-app
and then I made an app that worked, and npm start was able to start the server and run it.
But then if I want to make a version 2 of this app, and started by cloning the folder first:
cd ..
cp -r my-app my-app-02
to copy everything to my-app-02, and cd into that folder and do npm start, it will error, saying
> my-app#0.1.0 start /Users/username/code/TryContext/my-app-02
> react-scripts start
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module '../scripts/start'
I tried different ways, and tried npm rebuild and then npm start, and it worked. But I thought if you copy a directory "as is", then using it, npm start should start the server without needing to do anything? Why was that and what ways besides npm rebuild could fix it?
TL;RD: when you copy using cp -r it doesn't really preserve symlinks, it just copies the file contents instead. So npm start can't find necessary symlink in this particular case. One of the possible solutions is to use cp -a when coping, which preserves symlinks and avoids this issue.
Mode detailed answer is here
:)
I was new and want to learn ReactJS and I start to install a new empty folder with npx create-react-app . command. I have npm v.6.4.1. and when I try to execute the command, it gave me an error.
Error: EPERM: operation not permitted, mkdir 'C:\Users\LOGIVAR'
TypeError: Cannot read property 'get' of undefined
at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
if (npm.config.get('json')) {
^
TypeError: Cannot read property 'get' of undefined
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at process.emit (events.js:182:13)
at process._fatalException (internal/bootstrap/node.js:485:27)
Install for create-react-app#latest failed with code 7
I already do the same command on Laravel empty project, but I still gives me the same error.
Can you tell me what's the main cause problem and how to fix this?
EDIT: I already run the terminal as administrator, but I receive another error:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "2\AppData\Roaming\npm-cache\_npx\10552" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\LOGIVAR TY 2\AppData\Roaming\npm-cache\_logs\2019-01-23T04_18_56_036Z-debug.log
Install for create-react-app#latest failed with code 1
In my case the actual issue was due to the presence of a space in my windows user name folder. Which also appears to be the case here by looking at the first line of the stack trace,
Error: EPERM: operation not permitted, mkdir 'C:\Users\LOGIVAR'
Since there is no directory present named LOGIVAR its trying to run mkdir, for which its getting operation not permitted.
Following is how i fixed it thanks to citoreek, g8up & gijswijs
run npm config edit to edit your config, this will open up a text file in notepad or your configured editor,
then change cache path from
; cache=C:\Users\Gijs van Dam\AppData\Roaming\npm-cache
to
cache=C:\Users\GIJSVA~1\AppData\Roaming\npm-cache
Remember to remove the ; at the start,
next question would be how do we know to replace our user name with GIJSVA~1?
There are a couple of ways to target this,
Go to C:\Users open power Shell and execute following command
cmd /c dir /x
what this does is, list down all the directories in current directory along with their short names which aren't supposed to contain any spaces and normally are 6 characters or less in length. Copy that short name against your user name directory and use this in your cache path.
You will notice these short names only exist for directories either containing spaces or which are longer than 6 characters, for the rest of the directories their short names will be same as their directory name,
If you don't want to use above command, then simply remove all the spaces from your user name in your cache path, then take the first 6 characters of the user directory name and postfix it with ~1. You should also uppercase it, but it appears not to be making any difference.
After you are done with editing this file, save your changes then try again after closing any active power shell / bash process and reopening them.
First to install globally
npm install -g create-react-app
Create your new app
npx create-react-app your-app-name
this worked for me
Have you tried running this as admin?
add project name like this in your command:
npx create-react-app your-project-name
This is an issue with npx. Your computer name has a space in it. I'd recommend npm install -g create-react-app to get around the npx issue.
The above stated problem is due to the white space contained in the folder name. Best way is to make changes the config file.
Enter npm config edit to enter into your config file
Then change
; cache=C:\Users\Sinojia Zeel\AppData\Roaming\npm-cache
to
cache=C:\Users\SINOJI~1\AppData\Roaming\npm-cache
Don't forget to remove semi-colon from the front
The SINOJI~1 can be replaced with your folder name that contains white space.
Just take first 6 letters of your file name and in suffix add ~1(Capitalizing the file name is optional but often it is done)
Save the file and exit and re-run the npx create-react-app . command.
The below command worked for me:
npm install -g create-react-app
npx create-react-app project-name
If you are still facing this issue, after all of the above -
I had the same issue with the space in my name, I tried:
npm cache clear -f
npm cache verify
updated the cache path with the "~!"
And none of that worked for me, but then I ran:
npm -g install npm
npm init react-app my-app
... and it worked finally. Hope this helps someone out there
First install create-react-app
npm install create-react-app
then
npx create-react-app app-name
I ran into a similar issue while creating a React app from Linkedin Learning it had the command -
npx create-react-app my-website --use-npm
to create a new React application but didn't mention if it required any prerequisite.
So in order to run the above command, first install the create-react-app with
npm install -g create-react-app
I was also getting the same error:
Error: EPERM: operation not permitted, mkdir 'C:\Users\Username'
command not found: create-react-app
Then the below command worked for me:
npm install -g create-react-app
npx create-react-app project-name
Check your node version. If you are using like node v14 it might be the problem. In my case, since I switch between different versions with NVM, I than realized that I was using v14 rather than v16+.
To see your current node version, open your terminal and type:
node -v
I would like to run the following codepen on my PC?
http://codepen.io/kyleledbetter/pen/gbQOaV
I have nodejs installed, and have exported the codepen as a zip, extracted in -
but how do i actually run it?
I have tried 'http-server ./d' ? and 'npm run serve'. Sorry this is a newb question, but I can't find documentation on web for it, or in angularmaterialwebsite.
First install http-server package npmjs.com using following command
$ npm install http-server -g
then on you run a http-server pointing to your extracted folder using following command
$ http-server path/to/your/extracted/folder -p 8989