Can not resolve project name while creating react app

260 views Asked by At

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 [email protected]?

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: [email protected]
npm ERR! Found: [email protected]
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/[email protected]
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

  1. Clearing then verifying npx cache
  2. Uninstalling create-react-app globally.
  3. Updating npm
  4. Updating node
  5. Running command with and without @latest
  6. Running command with and without --template typescript
  7. Using the --use-npm flag.
  8. Adding --legacy-peer-deps to command.
  9. 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"
    ]
  }
}
1

There are 1 answers

0
Luke Martin On

The problem was caused by an issue with the testing library installed by default with React. It may have already been fixed.