NPM Start 在 VSCode REACT 开发中停止工作

NPM Start stop working in VSCode REACT Development

哇..这阻止了我的发展。 NPM START 和 F5 Debug 停止工作。 Index.html 存在于 PUBLIC 中。我在下面包含了 index.html 的内容。 我在 Windows 环境中。 显示: ...

Could not find a required file.
  Name: index.html
  Searched in: C:\React-Springboot-CRUD-App\public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-frontend@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1

... 在日志中获取此信息。 第 8 行有一个奇怪的路径,在错误日志中带有下划线: ...

C:\React-Springboot-CRUD-App\node_modules\.bin;

...

那么解决方法是什么?这个路径在哪里定义的?

...

    0 info it worked if it ends with ok
    1 verbose cli [
    1 verbose cli   'C:\Program Files (x86)\nodejs\node.exe',
    1 verbose cli   'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js',
    1 verbose cli   'start'
    1 verbose cli ]
    2 info using npm@6.14.13
    3 info using node@v14.17.0
    4 verbose run-script [ 'prestart', 'start', 'poststart' ]
    5 info lifecycle react-frontend@0.1.0~prestart: react-frontend@0.1.0
    6 info lifecycle react-frontend@0.1.0~start: react-frontend@0.1.0
    7 verbose lifecycle react-frontend@0.1.0~start: unsafe-perm in lifecycle true
    8 verbose lifecycle react-frontend@0.1.0~start: PATH: C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\React-Springboot-CRUD-App\node_modules\.bin;C:\Python39\Scripts\;C:\Python39\;C:\Program Files\ImageMagick-7.0.8-Q16;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared.0\DLLShared\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC0\Tools\Binn\;C:\Program Files (x86)\dotnet\;C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\Rob.Sobol\AppData\Local\Microsoft\WindowsApps;
C:\Users\Rob.Sobol\.dotnet\tools;C:\Users\Rob.Sobol\AppData\Roaming\npm;C:\Users\Rob.Sobol\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\Rob.Sobol\AppData\Local\GitHubDesktop\bin
    9 verbose lifecycle react-frontend@0.1.0~start: CWD: C:\React-Springboot-CRUD-App
    10 silly lifecycle react-frontend@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
    11 silly lifecycle react-frontend@0.1.0~start: Returned: code: 1  signal: null
    12 info lifecycle react-frontend@0.1.0~start: Failed to exec start script
    13 verbose stack Error: react-frontend@0.1.0 start: `react-scripts start`
    13 verbose stack Exit status 1
    13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
    13 verbose stack     at EventEmitter.emit (events.js:376:20)
    13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
    13 verbose stack     at ChildProcess.emit (events.js:376:20)
    13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
    13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    14 verbose pkgid react-frontend@0.1.0
    15 verbose cwd C:\React-Springboot-CRUD-App
    16 verbose Windows_NT 10.0.19041
    17 verbose argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "start"
    18 verbose node v14.17.0
    19 verbose npm  v6.14.13
    20 error code ELIFECYCLE
    21 error errno 1
    22 error react-frontend@0.1.0 start: `react-scripts start`
    22 error Exit status 1
    23 error Failed at the react-frontend@0.1.0 start script.
    23 error This is probably not a problem with npm. There is likely additional logging output above.
    24 verbose exit [ 1, true ]

...

index.html 的上下文 ...

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <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>
  <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
  
  </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>

...

好吧,我导航到正确的子目录,重新安装了一些软件包,运行 NPM AUDIT FIX,它最终又开始工作了。 部分常识,部分巫术/

我看到它最终开始工作了,但我只想在这里补充一点,您可以使用 npx start 而不是 npm start。