Why is my npx create-react-app ./ not working? - reactjs

npm WARN config global --global, --local are deprecated. Use --location=global instead.

Go to folder C:\Program Files\nodejs
You have to edit four files named npm, npm.cmd, npx, npx.cmd
Open the files in a text editor, like Visual Studio Code
Replace prefix -g with prefix --location=global in all four files
Save all (if asked, save as administrator)

Related

The command create-react-app doesn't run, it creates an error

$ npx create-react-app awesomeApp
Error: EPERM: operation not permitted, mkdir 'C:\Users\'
command not found: create-react-app
This is a bug within npm if you have your username as "FirstName LastName"
A quick fix for this is -
If your UserName is - Anand Chavan all you need to use at
is ANANDC~1. i.e FirstName+First_Letter_of_your
LastName+~1 (All in capital)
npm config set cache "C:\Users\<UserNameWorkAround>\AppData\Roaming\npm-cache" --global
Example config for - Anand Chavan as username.
npm config set cache "C:\Users\ANANDC~1\AppData\Roaming\npm-cache" --global
I faced the same issue as well in Windows. And I solved it as below:
It may be due to your username having space in between your username. If so, kindly try this in your command prompt if you're using Windows:
npm config set cache "C:\Users\Your Name\AppData\Roaming\npm-cache" --global
Thereafter, try again: npx create-react-app awesome
I encountered EPERM errors while trying to clean install create-react-app and running an older version of it.
Excluding the node_modules folder from Windows' Virus & Threat Protection (answer found here) and then running my terminal as an administrator fixed it for me.

Why I got Error while Creating React App?

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

react-360 did not create project

I installed react-360 using npm install -g react-360-cli.
But react-360 init Hello did not create any directory.
I am using ubuntu 14.04.
Any errors you have encountered?
1) You could be having permission issues while trying to install packages in node_modules folder. Try changing the permission to the folder like:
sudo chown -R USERNAME /FILE_PATH
2) Try updating node version if 1st doesn't work.

error: import pychart , during install source code odoo 9.0

I wrote so many thing in requirements.txt and reinstalled but it didn't work out. I installed odoo 9.0 source code for windows. The command prompt is showing error:
from pychart import *
What do I need to write in requirements.txt for pychart?
As i just ran into the same problem unrelated to odoo.
The following command solved it for me:
pip install Python-Chart
To install the python packages for odoo you can use below command found from this detailed odoo install guide
cd /tmp && wget https://raw.githubusercontent.com/odoo/odoo/9.0/requirements.txt && sudo pip install -r requirements.txt
It will install all the python dependacy in just one command.
Hope this helps.
You have to install that package before you use that, If are on ubuntu command is pip install pychart and if you are on windows the command is c:\Python27\Scripts\pip.exe install pychart.I assume you have installed python on default folder c drive.
Why don't you create a module like install_module and on depends you can add required list of module to install. If you install that module it'll automatically install all depended module. I'm using this same. Instead of command prompt it'll be quite easy too. You can view the depends module list in Technical Data of that install_modules.
I Hope it'll be helpful.

npm / yeoman install generator-angular without sudo

I tried to install generator-angularjs using Yo (Yoeman) without sudo:
npm install -g generator-angular
I get:
Error: EACCES, mkdir '/usr/lib/node_modules/generator-angular'
When I type in sudo yo, yo tells me that I should not use sudo (which is perfectly understandable).
I have a ~/node_modules directory - why doesn't yo install its packages there?
Generators are designed to be installed globally. Otherwise, you always have to install the generator you're about to use in each project, which is unnecessarily painful. Also, you don't get to see the lovely yo menu which lists you all the available generators (unless of course, you install them all locally):
Setting up npm for global installation
So, how do we get npm to install packages globally? As you correctly said, you should never, ever run yo with sudo. There are lots of different solutions to this problem and you can spend hours discussing their pros and cons religiously.
I personally dislike installing my user packages into the global /usr/ folder. /usr/ is for software that is shared across all users on the computer. Even if it's only using the machine, there are still good reasons to respect the way the Unix file system hierarchy is designed. For example if you decide at one point to wipe your whole node installation.
My preferred way of enabling npm to install packages globally without breaking out of $HOME is to set a local node prefix. This is as easy as running
echo 'prefix = ~/.node' >> ~/.npmrc
in your local shell. After that, you want to adjust your $PATH, to point to the new installation destination for global node executables by adjusting your favorite shell's config. E.g. by adding
export PATH="$PATH:$HOME/.node/bin"
to your ~/.bashrc. After that, you can happily run npm install -g generator-angular without sudo, without running into permission conflicts and if something is completely broken and you want to start from scratch, all you need to do is remove your ~/.node directory.
Thanks to #passy I managed to finally get this working on ubuntu 13.04 (in case anyone is having similar set up issues) with the following :
sudo apt-get update
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
trying to run:
npm install -g yo
resulted in
Error: EACCES, mkdir '/usr/lib/node_modules/yo'
Fixed using:
echo prefix = ~/.node >> ~/.npmrc
echo 'export PATH=$HOME/.node/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
Running:
yo webapp
resulted in:
Error: EACCES, permission denied '/home/username/.config/configstore/update-notifier-yo.yml'
Fixed using:
sudo chown yourusername:yourusername /home/yourusername/.config/configstore/update-notifier-yo.yml
hi in my case (on ubuntu 12.04), the prefix addition in ~/.npmrc did not changed anything.
if so, build the node package by yourself and install it in /opt/node or /home/user/.node.
I had an almost identical error involving a rogue .yo-rc.json file in my root directory from a project I installed earlier. Yeoman was switching cwd from the installation dir to root dir half way through the installation, but was only outputting the EACCESS permissions error without any details that the installation directory was /. It took ages to figure out why this was, and involved debugging through the Yeoman source, but I eventually learned that Yeoman will look up through the directory tree until it finds a .yo-rc.json, and generate the code there by calling chdir to the new location.
Yeoman should maybe check that the user has write permissions for the directory. Alternatively, it could mention in the output either that the cwd has changed, or print the name of the installation directory if where it finds .yo-rc.json is different than cwd.
The command for finding rogue .yo-rc.json files
sudo find / -name .yo-rc.json
From yoeman getting started page appears the command:
yo doctor
In my case, $NODE_PATH (which in my case, Ubuntu 14.04, is defined in /etc/profile.d) isn't the same than npm root. Adding in npm root in $NODE_PATH solve the problem.
I have been trying to get yeoman to play nice with my vagrant box and this is what I had to do to install npm packages globally without sudo on ubuntu:
1. Create the directory to store global packages
$ mkdir "${HOME}/.npm-packages"
2. Tell npm where to put any packages installed globally
Insert this snippet into your ~/.npmrc file:
prefix=${HOME}/.npm-packages
3. Make sure that npm can locate installed binaries et cetera
Insert this snippet into your .bashrc/.zshrc:
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
// `unset` `manpath` to allow inheritance from `/etc/manpath` with
// the `manpath` command
unset MANPATH // remove this line if you have previously modified `manpath`
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
4. Run the following or restart terminal
$ source ~/.bashrc
Hope this helps anyone who finds themselves in a similar situation.

Resources