Reputation: 73
i got an error while trying to create react native app using npx npx
react-native init AwesomeProject
like the docs said. But i got an error messages
npm ERR! code ENOLOCAL npm ERR! Could not install from "Indigo\AppData\Roaming\npm-cache_npx\3192" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in: C:\Users\Durio Indigo\AppData\Roaming\npm-cache_logs\2020-07-08T08_20_54_191Z-debug.log Install for react-native@latest failed with code 1
i know it's not from the npx because i tried to create react app with npx and it works. Am I the only one who had this?
Upvotes: 6
Views: 12796
Reputation: 780
init has deprecated. However you can still use :
npx @react-native-community/cli@latest init newapp
source : https://reactnative.dev/docs/getting-started
Upvotes: 2
Reputation: 5094
For MAC users
For the latest version, npm won't let you clear the cache. So to fix this issue, run;
npm cache verify
If throwing an error run this command (will be shown in the error too);
sudo chown -R 501:20 "/Users/username/.npm"
After that, test whether the cache is verified or not by running the first command again. If it worked, you are good to go. Run the react native cli command to create the new project and that should work fine.
npx react-native@latest init yourproject
Upvotes: 0
Reputation: 65
I have faced the same issue, do nothing just a quick fix.
first, run the command npm i react-native@latest -g
then create your project with your command i.e npx react-native init myProject
Upvotes: 3
Reputation: 4251
This is an issue in node which is caused by white space in user name between first-name and last-name in windows.
run the following command after replacing firstname with your windows user firstname in command prompt with administrator access
npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global
Upvotes: 2
Reputation: 73
we should check the android SDK path on environment variable. Make sure there is no white space on the SDK path and platform-tools path
Upvotes: 0
Reputation: 321
I had you try npm cache clear
and if using windows you can run command npx react-native init AwesomeProject
in Command promt
using Run as Administrator
Upvotes: 3