I am trying to setup a ReactJS app on Windows using the following command:
npx create-react-app my-app
and the output is coming as :
PS C:\Users\santu\React-JS> npx create-react-app my-app
node:fs:1349
handleErrorFromBinding(ctx);
^
Error: EPERM: operation not permitted, mkdir 'my-app'
at Object.mkdirSync (node:fs:1349:3)
at Object.module.exports.makeDirSync (C:\Users\santu\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\make-dir.js:23:13)
at createApp (C:\Users\santu\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:257:6)
at C:\Users\santu\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:223:9
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
errno: -4048,
syscall: 'mkdir',
code: 'EPERM',
path: 'my-app'
}
Solution 1
To make this run..You need to run my cmd as an administrator.
So run the below commands:
Run cmd as administrator
Run npm config edit (You will get notepad editor)
Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
Then npm start works in a normal console.
OR
Solution 2
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 will help.
Edit: Above solution might work but it's not recommended way of solving this issue. Please refer the Link
I referred to the solution given at the bottom, also some other posts to use the below too:
command: npm config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global
try to update your npm Using npm#latest command to update the node package manager.
npm install npm#latest -g
after updating your package try
npx create-react-app my-app
you should be able to run without any issues
Run your cmd as administrator
or
Run vs code as administrator
Related
I am trying to create a Strapi application with MongoDB and I am following the docs on the website, but when configuring the connection, I get this error and I am not understanding why.
Error I get everytime (screenshot)
Log's error (screenshot)
Error:
"Connection test failed: Command failed: npm install --prefix /var/folders/gb/519s_wwn1ps0c0skqw7_03140000gn/T/strapi40136a8b0f29 strapi-connector-mongoose#3.5.4
npm ERR! Cannot read property 'spec' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/red/.npm/_logs/2021-04-08T09_37_12_689Z-debug.log"
MongoDB was installed using Brew and is running as a service.
Node version is 14.16.1.
NPM version is 7.8.0.
Never had a problem like this before with any sort of package or similar.
I already tried to: uninstall MongoDB and reinstall it, reinstall Node and npm.
When I run npm install -g npm-reinstall I get this instead and I think it is related to the problem:
Error screenshot
What I need to fix this?
I fixed this issue by changing the registry of npm config.
npm config set registry https://registry.npmjs.org/
I had to downgrade npm to its previous version to avoid this error.
npm install -g npm#6
I have installed node version 12.6.1 on the windows machine.
I have been trying to create react app on my machine using the following command:-
npx create-eact-app my-app
the error:-
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Ahmad\AppData\Roaming\npm-cache\_npx\2904" 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\Saood Ahmad\AppData\Roaming\npm-cache\_logs\2020-03-01T06_56_47_636Z-debug.log
Install for [ 'create-react-app#latest' ] failed with code 1
screenshot error screen shot
please guide me through
Thanks
this error occurred because you have a space in your username.
you can solve this problem by installing create-react-app globally:
npm install -g create-react-app
then simply run:
create-react-app my-app
(be carefull you have a typo in your explanation:
npx create-eact-app my-app => npx create-react-app my-app
This can be solved by making sure you install create-react-app in your machine.
Run the following commands, either you install create-react-app globally or not
npm install create-react-app
or
npm install -g create-react-app
--registry https://registry.npmjs.org is been used to get around artifactory alike proxy when install with npm install But I want to do similiar thing with npm xxx because I encounter
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="Artifactory Realm"
when try to do npx create-react-app myapp
Is that something possible?
I literarily can't find any info about this online!
You can run something like:
npm_config_registry=https://registry.npmjs.org npx xxx
This is suggested by the npm team. I ran into this same problem, but that was because I needed to have npx point to a private registry.
Using the command prompt, I am trying to install angular CLI and it fails. I have npm version 5.5.1 and node version v8.9.1. I am trying to install angular cli using the command
npm install -g #angular/cli#latest
and it fails with the error:
npm ERR! code E404
npm ERR! 404 Not Found: #angular/cli#latest
npm ERR! A complete log of this run can be found in:
I look at the log file and I see its trying to fetch the package from a location that doesn't exist. Not sure from where it gets pulled. How do I fix this location path and install angular cli. Same happens when I try to install typescript or any other npm package. all of them try to install from the location mentioned below and it fails with 404
8 http fetch GET 404
http://nuget.feed.xyz.corp:8729/npm/FeedNPM/#angular%2fcli 109ms
9 silly fetchPackageMetaData error for #angular/cli#latest 404 Not Found:
#angular/cli#latest
10 verbose stack Error: 404 Not Found: #angular/cli#latest
npm config set registry http://registry.npmjs.org
NPM registry documentation
Try first this commands (in windows run as administrator)
npm config set registry http://registry.npmjs.org
npm install -g #angular/cli
if still not working let's update NPM and nodejs by running this commands
npm -g install npm
npm cache clean -f
npm install -g n
then try to run
npm install -g #angular/cli
This should solve this problem
in my case it was .npmrc file in my project dir, which kept overwriting my global registry url. As soon as I deleted it, I could finally use npm install
Add a .npmrc file in the root of the project. .npmrc will look like below -
#xy:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/
#xy-app:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/
And Delete all the field eg - email , auth etc.
Find out what is the registry url of your application and put it into the registry.
Then run command - npm install
And it will work.
It was giving the same error for me when I use office network/vpn as they have 'umbrella' DNS security shield. To solve this issue, connect to personal network and type the below commands:
npm config set registry http://registry.npmjs.org
npm install -g #angular/cli
Alternative, another option to avoid 404 npm error
check if your terminal is in the root directory, if not your npm scripts will not execute
because it will not be able to see the package.json
I had same problem with a private package.
Need to:
npm adduser
npm login
I spent hours on this.
I had to follow the below steps to get it to work (mac).
Delete my LOCAL (not project) .npmrc by running:
rm /Users/<NAME>/.npmrc
Then set the registry:
npm config set registry https://registry.npmjs.org/
Then follow the steps for logging in to npm:
npm login
Check what's in your config list by running:
npm config list
It should look like this:
//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org/"
Hope it works for you too.
change your access level to public. type this in the terminal
npm --access=public
install your angular.
sudo npm install #ngular/cli
In my case, that's a typo error:
change trct-js-sdk to trtc-js-sdk saved my life.
My solution was as follows because I had a dependency on a private package. If you see the dependency in package.json defined in the format #scope/package, then #scope tells you that it's a scoped package that might be private.
Get the private package owner to grant you access to the package
Upgrade npm
Upgrade node
Add registry using HTTPS (not HTTP), e.g. npm config set registry https://registry.npmjs.org
Do "npm login"
Now run the build
Uninstall NPM & nodejs and install the right way NPM (Ubuntu)
sudo with npm is not recommended
To Uninstall
sudo apt-get remove nodejs
sudo apt-get remove npm
or
sudo apt-get purge nodejs
Followed by proper installation
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
To confirm open a new terminal run:
$ command -v nvm
Latest LTS release of NodeJS:
$ nvm install --lts
Set default environment
$ nvm alias default lts/*
Worked for me
I got
error 404 'dotnev#*' is not in this registry.
Deleted .npmrc file in 2 folders back over my project root
and then in the project root folder typed:
npm i dotenv
copied from:
https://www.npmjs.com/package/dotenv
Just run sudo npm config set registry http://registry.npmjs.org and then update your npm.
It is an network error , check your network connection and try to install it again.
the only command line "npm -g install npm" solved the issue for me!
the following link can be helpful to dig deep for a better understanding.
Thanks a lot.
I have installed create-react-app exactly as instructed on the facebook instruction page (https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html):
First, install the global package:
npm install -g create-react-app
I did this. It appeared to work fine - the file was installed to
users/*name*/.node_modules_global/lib/node_modules/create-react-app
I'm not really sure why global install takes it to this path, but there you have it.
Next instruction:
Now you can use it to create a new app:
create-react-app hello-world
Couldn't be simpler, right? But Terminal spits out this at me:
-bash: create-react-app: command not found
It's probably something very simple I'm missing but I don't really know where to look. If anyone can help I'd really appreciate it!
Note: I'm using Node v6.3.1, and npm v3.10.3
You are able to apply the following solution:
$ npm config set prefix /usr/local
$ sudo npm install -g create-react-app
$ create-react-app my-app
The environment variables are not set properly.
When you run the create-react-app it shows you a path along with the error. Copy that path and add it in the environment variable.
Alternatively you can use the command:
npx create-react-app <app_name>.
This will do the work for you.
Your Node setup looks incorrect. It's not an issue with Create React App—it seems like you can't run any global Node commands.
It looks like ~/.node_modules_global/bin is not in your PATH environment variable so it can't execute global commands. That's just how Bash works—it can't guess where the command lies, you need to tell it. I would assume Node installation should do this by default but it depends on how you installed Node.
So make sure that directory is in your PATH and try again. If you use Bash, add this to your .profile and then restart the Terminal:
export PATH=$HOME/.node_modules_global/bin:$PATH
Try this. It worked or me. I found this in the React documentation. "Npx" is not a typo. It's a package runner tool that comes with npm 5.2+.
npx create-react-app my-app
In 2020 Dec 17
Install Nodejs & npm
sudo apt update
sudo apt install nodejs
sudo apt install npm
if you install maybe show you this like errors for Reactjs setup.this helpful for you
npm install -g create-react-app
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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! /home/user/.npm/_logs/2020-12-17T14_16_02_442Z-debug.log
then When you type after this
create-react-app test-react-app
Show you in terminal
zsh: command not found: create-react-app
you fix this error by using this command
sudo npm install -g create-react-app
create-react-app test-react-app
I hope work fine for you also.
Use npx instead of npm.
Check this out-> https://reactjs.org/docs/create-a-new-react-app.html#create-react-app
Answers given above are right but I want to share some things that I also faced and these are basics.
To setup react project
If you want to create a node environment
$ sudo apt-get update
$ sudo apt-get install nodejs
(Sometimes we can also run without sudo; but sudo means install in system level.)
$ sudo apt-get install nodeenv
$ nodeenv env
$ source /bin/activate
If you want to create new react app then
$ npm install create-react-app
If an error occurs create-react-app: command not found then install with -g, it happens because node is installed globally and it is not getting the node in local
$ npm install -g create-react-app
$ create-react-app app_name
$ cd app_name
app_name$ npm start
I hope you already installed Node package manager(npm).
now run npm install -g create-react-app, if everything fine then you can use create-ract-app command.
if you are getting any permission error just sudo npm install -g create-react-app.
I hope it will work.
Happy Hacking.
if you face following this problem:
create-react-app: command not found
solution:
sudo npx create-react-app react_spa
cd react_spa
sudo npm start
I hope its work.
If above answers are not working, then try this
update the npm version (npm install npm#latest -g)
clear the cache (npm cache clean --force)
create the react project (npx create-react-app myapp)
(while running the 3rd command, make sure that create-react-app is already installed in the pc)
This is how I get it fixed.
Step # 1:- Make sure, Node js and React js is installed globally. You can check Nodejs by
node --version . If not installed, install and run
export PATH=$HOME/.node_modules_global/bin:$PATH
Step # 2:- Clean your npm cache by following the command
npm cache clean --force
run
sudo npx create-react-app your-app-name
And that's it. you're done.
Please note, This solution worked for me for MAC OS
I tried all methods listed above and in other sites. They weren't working for me. But for some reason I decided to add the create-react-app directory into my system variables as a last ditch method and to my surprise this actually worked.
I faced a similar challenge but on running the command
npm i tar
I was able to resolve the issue.