Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the project dependency tree. Start project error #8588

Closed
Fab2295 opened this issue Mar 1, 2020 · 5 comments
Closed

Problem with the project dependency tree. Start project error #8588

Fab2295 opened this issue Mar 1, 2020 · 5 comments

Comments

@Fab2295
Copy link

Fab2295 commented Mar 1, 2020

Hi, all!

I created the project using:

npx create-react-app my-app
yarn create react-app my-app
npm init react-app my-app

I can't start my react app, but I am getting the following error:

here might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "webpack": "4.41.5"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

  C:\Users\<user>\node_modules\webpack (version: 4.39.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.    
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.   

  6. Check if C:\Users\<user>\node_modules\webpack is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls webpack in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed webpack.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

I already tried the steps, but it didn't solve

Did you try recovering your dependencies?

Yes

Environment

npx create-react-app --info

  Environment Info:

  current version of create-react-app: 3.4.0
  running from C:\Users\<user>\AppData\Roaming\npm\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  Binaries:
    Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.21.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.11.3 - C:\Users\<user>\AppData\Roaming\npm\npm.CMD
  Browsers:
    Edge: 44.18362.449.0
    Internet Explorer: 11.0.18362.1
  npmPackages:
    react: ^16.13.0 => 16.13.0
    react-dom: ^16.13.0 => 16.13.0
    react-scripts: 3.4.0 => 3.4.0
  npmGlobalPackages:
    create-react-app: Not Found

npm ls webpack

-- react-scripts@3.4.0
  `-- webpack@4.41.5 

Steps to reproduce

  1. npx create-react-app my-app
  2. cd my-app && npm start or yarn start
  3. error is triggered

More information

Package.json

{
  "name": "fire-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "react": "^16.13.0",
    "react-dom": "^16.13.0",
    "react-scripts": "3.4.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
@Aakashdeveloper
Copy link

Add .env with "SKIP_PREFLIGHT_CHECK=true"

@Fab2295
Copy link
Author

Fab2295 commented Mar 1, 2020

Thanks!!

@Fab2295 Fab2295 closed this as completed Mar 1, 2020
@schen3
Copy link

schen3 commented Mar 2, 2020

@Aakashdeveloper Why need to skip preflight check? Do you know any other solution instead of disable the preflight check.

@Fab2295
Copy link
Author

Fab2295 commented Mar 3, 2020

Yes, why?

@Aakashdeveloper
Copy link

@schen3 @Fab2295 I tried this solution and this is working for me I haven't explored any other solution.
Skip is required there are some dependencies in new create-react-app like webpack which is causing an issue.

This was referenced Mar 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants