0

I can't install react app normaly.The src and public folder is missing. I'm using node v18.13.0 and **npm v9.4.0 **

1

I did this command npx create-react-app my-site.And I expecting all dependencies to be installed but I got an error message

vimuth
  • 5,064
  • 33
  • 79
  • 116
MESCH
  • 1
  • 3

2 Answers2

1

Installation

To start a new Create React App project with TypeScript, you can run:

npx create-react-app my-app --template typescript

or

yarn create react-app my-app --template typescript

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.

Global installs of create-react-app are no longer supported.

Troubleshooting

If your project is not created with TypeScript enabled, npx may be using a cached version of create-react-app. Remove previously installed versions with npm uninstall -g create-react-app or yarn global remove create-react-app (see #6119).

If you are currently using create-react-app-typescript, see this blog post for instructions on how to migrate to Create React App.

Constant enums and namespaces are not supported, you can learn about the constraints of using Babel with TypeScript here.

See here for full details: https://create-react-app.dev/docs/adding-typescript/

  • thanks for your answer but i tried to install locally and i still got the same error. Could you please tell me if my version of node could be causing a problem? I installed Node.js v18.13.0. Thanks in advance – MESCH Jan 31 '23 at 22:24
0

When the system has a globally installed CRA (create-react-app) and we try to create a new app with npx it fails due to the conflict. In order to fix this, we need to remove the global installation and then use npx to install a new app.

We can uninstall with:

sudo npm uninstall -g create-react-app

and then clear the npx cache

npx clear-npx-cache

There is an error with the command to create react app, the following is the correct one:

npx create-react-app my-app --template typescript
Ayush S
  • 99
  • 2
  • thanks for your answer but i tried to install locally and i still got the same error. Could you please tell me if my version of node could be causing a problem? I installed Node.js v18.13.0. Thanks in advance – MESCH Jan 31 '23 at 22:26
  • how did you install node and the global package? The above should work for Node v18. Depending on your node installation method, we should investigate into where the directory for global installation is? For `Yarn`: the directory is: Mac:`~/.config/yarn/global` Linux: `/usr/local/share/.config/yarn/global` Windows: `C:\Users\\AppData\Local\Yarn\config\global` – Ayush S Feb 02 '23 at 16:04
  • I installed node from node.org by downloading the recommended version for my system which is node v18.14.0 – MESCH Feb 02 '23 at 20:05
  • Did you check for the global installation? For yarn, the above were the directories. For npm, check Rohit's answer (https://stackoverflow.com/a/5926706/10162015) If you find CRA there, please delete it. – Ayush S Feb 03 '23 at 06:26