首页 > 解决方案 > 在“create-react-app”之后“npm start”将不起作用

问题描述

我已经尝试了一切。查看 Windows 10 中的“PATH”变量

- 多次重新安装节点和多个版本 - 从程序文件夹以及 AppData 和用户文件夹中删除所有节点文件和 npm 文件。- 我终于让反应应用程序工作了,但是当我每次执行“npm start”时,它都会给我错误。

-我也删除了节点模块和 package-lock.json 文件,但仍然没有解决方案。

PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1> npm start

> maryam1@0.1.0 start
> react-scripts start

npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\Imran\Desktop\zertomastery\19_react\maryam1
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Imran\AppData\Local\npm-cache\_logs\2021-07-18T18_17_31_571Z-debug.log-debug.log
PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1>

我已经删除了 node_modules 文件夹和 package-lock.json 并完成了 npm install

- 删除 node_modules 和 package.json 后 npm install 的结果。

PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1> npm start   > npm install
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has 
been deprecated and is no longer supported or maintained                                                      act\maryam1   
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.co find a file.om/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.1: The querystring 
API is considered Legacy. new code should use the URLSearchParams API instead.                                              18_17_31_571Z-debug.log
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will bregs\2021-07-18Tak on node v14+. Upgrade to chokidar 3 with 15x less dependencies.                                            >
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated querystring@0.2.0: The querystring 
API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm 
install @sideway/address'
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated rollup-plugin-babel@4.4.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() 
in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details. 
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() 
in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details. 
npm WARN deprecated @hapi/hoek@8.5.1: This version has 
been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no 
longer maintained and not recommended for usage due to 
the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a 
slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of 
core-js.
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\Imran\Desktop\zertomastery\19_react\maryam1\node_modules\core-js
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:   
npm ERR!     C:\Users\Imran\AppData\Local\npm-cache\_logs\2021-07-18T18_22_24_801Z-debug.log
PS C:\Users\Imran\Desktop\zertomastery\19_react\maryam1

在执行了许多命令和事情之后,当执行“npm start”时我没有得到这个,我切换到 bash

Imran@DESKTOP-3331IKE MINGW64 ~/Desktop/zertomastery/19_react/maryam1 (main)
$ npm start

> maryam1@0.1.0 start
> react-scripts start

node:internal/modules/cjs/loader:355
      throw err;
      ^

Error: Cannot find module 'C:\Users\Imran\Desktop\zertomastery\19_react\maryam1\node_modules\loader-runner\lib\LoaderRunner.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:347:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:560:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:913:27)
    at Function.Module._load (node:internal/modules/cjs/loader:772:27)  
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (C:\Users\Imran\Desktop\zertomastery\19_react\maryam1\node_modules\webpack\lib\NormalModule.js:16:36)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)       
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\Users\\Imran\\Desktop\\zertomastery\\19_react\\maryam1\\node_modules\\loader-runner\\package.json',
  requestPath: 'loader-runner'
}

Imran@DESKTOP-3331IKE MINGW64 ~/Desktop/zertomastery/19_react/maryam1 (main)
$

标签: npmnpm-start

解决方案


尝试这个,

  1. npm cache clean
  2. npm install
  3. npm start

推荐阅读