OS: Windows
for creating react app using npx i've write the following command:
npx create-react-app myapp
it shows this error:
npm ERR! Could not install from "myusername\AppData\Roaming\npm-cache\_npx\19748" as it does not contain a package.json file.
How can i fix it?
this error occurs usually when name of the PC contain a space like
mycomputer name
you should fix this by redefine your npm cache root There is a simple workaround to fix this problem. 8.3 DOS path format should be used. Open command prompt in administration mode then cd to C:\Users and run this command :
C:\Users>dir /x
and find the short path for your desired directory i.e. username let us say it is MYCOMP~1 (it's not always MYCOMP~1 ) try:
npm config set cache "C:\Users\MYCOMP~1\AppData\Roaming\npm-cache" --global
be careful for space character in the pc name you should use the one you got from command prompt instead and now use:
npx create-react-app myapp
happy coding!!!