I am attempting to install React with Typescript, but I keep getting a weird error.
Please note myprojectname
is the root repository directory that I am installing the React app into. For some reason it is trying to resolve myprojectname@0.1.0
?
Error
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1355 packages in 1m
171 packages are looking for funding
run `npm fund` for details
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: myprojectname@0.1.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"<18.0.0" from @testing-library/react@12.1.5
npm ERR! node_modules/@testing-library/react
npm ERR! @testing-library/react@"^12.0.0" from the root project
My attempts to solve the issue
- Clearing then verifying npx cache
- Uninstalling create-react-app globally.
- Updating npm
- Updating node
- Running command with and without
@latest
- Running command with and without
--template typescript
- Using the
--use-npm
flag. - Adding
--legacy-peer-deps
to command. - Modifying command to create the react app in a nested directory.
Command
npx create-react-app@latest . --template typescript --use-npm
Outputs
npm -v
>8.6.0
node -v
>v17.8.0
Package.json
{
"name": "myprojectname",
"version": "0.1.0",
"private": true,
"dependencies": {
"cra-template-typescript": "1.1.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "5.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}