Error when launching Reset

Asked

Viewed 1,289 times

1

When I try to launch the React after creating-React-app and having already created the folder this error appears

Could not find a required file.
  Name: index.html
  Searched in: C:\Users\LUIS MARQUES\Documents\JS\curso\udemy
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is li

npm ERR! A complete log of this run can be found in:

Since the package.json file is so:

{
  "name": "exercicios",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "16.12.0",
    "react-dom": "16.12.0",
    "react-scripts": "3.2.0"
  },

  "scripts":{
    "start":"react-scripts start",
    "build":"react-scripts build",
    "test":"react-scripts test",
    "eject":"react-scripts eject"
  }

}
  • Not much to say... file not found. C.R.A. creates a "Static" folder that should have an index.html inside. If not, there may have been some problem in the creation of the project... just my kick.

3 answers

1

You have to create a folder called public with the file index.html.

Here is the structure of the HTML file you have to create:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

    <!--
      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> MEU SIT </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>

You also have to create the manifest.json and favicon.ico files.

But to make your life easier and uncomplicated you should use the very NPX package that Reactjs offers you.

In the official Reactjs documentation you can find a guide that is very easy to understand and very easy to follow, and take a look at the documentation before you start using to understand how life cycles work.

  • I had already used npx but it still didn’t work

  • Usa npx create-react-app my_app and put out the command for us?

  • This in the answer below,but after that when I enter the folder I created and I start npm it gives the same error I posted

  • You can post the answer to the installation for us take a look?

  • I put it down there, it doesn’t even generate the scripts in package.json, but even when I manually placed it and then turned the installation into an error

  • If what you’re talking about is his last comment, that’s out of Yarn’s command and not npx’s.

  • Oh yes sorry I thought I had put, A complete log of this run can be found in: npm ERR! C: Users LUIS MARQUES Appdata Roaming npm-cache_logs 2019-11-28T17_54_05_939Z-debug.log

  • What’s inside debug.log? You opened it to take a look?

Show 3 more comments

0

yarn add v1.19.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-scripts > @typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev 
|| >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.19.2", while you're on "1.19.0".
info To upgrade, download the latest installer at "https://yarnpkg.com/latest.msi".
success Saved 7 new dependencies.
info Direct dependencies
├─ [email protected]
├─ [email protected]
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 236.05s.

0

It seems to me that you forgot to enter the folder Crete-React-app created. After giving the command create-react-app, type in command prompt: cd pasta-do-seu-app and enter. Enter npm start again and see if it works.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.