简体   繁体   中英

Getting white screen on running npm start in my react js project

So is <strictmode causing this problem ??? 2 I am getting a white screen while i am trying to run npm start . The npm start works but I am getting a white screen on http://localhost:3000/ . I tried to add {"homepage": ".",} to my index.html file ,still i am getting the same error ? Could you please tell me where i am doing things wrong ? Also i tried to debug it through google console but it shows nothing.3

index.html file:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href=" https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://unpkg.com/purecss@2.0.3/build/grids-responsive-min.css">
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

**package.json file** 

    {
      "name": "chatapp",
      "version": "0.1.0",
      "homepage": ".",
      "private": true,
      "dependencies": {
        "@testing-library/jest-dom": "^4.2.4",
        "@testing-library/react": "^9.3.2",
        "@testing-library/user-event": "^7.1.2",
        "firebase": "^7.19.1",
        "font-awesome": "^4.7.0",
        
        "react": "^16.13.1",
        "react-dom": "^16.13.1",
        "react-loading": "^2.0.3",
        "react-router-dom": "^5.2.0",
        "react-scripts": "3.4.3",
        "react-toastify": "^6.0.8"
      },
      "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"
        ]
      }
    }

i tried ur code and i'ts giving me quick response . I created new file means change a code in ur index.js with :

在此处输入图片说明 在此处输入图片说明

code:

import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<>hello</>,
document.getElementById('root')
);

and then see the response time.

This will fix the error.

command

npm install chalk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM