简体   繁体   English

ReactJS npm 启动错误。 项目依赖树的问题

[英]ReactJS npm start error. Problem with project dependency tree

Terminal终端

npm start

> matchstatz@0.1.0 start C:\Users\07\OneDrive\Desktop\matchstatztask\matchstatz
> react-scripts start


There 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:

  "babel-loader": "8.1.0"

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

  C:\Users\07\node_modules\babel-loader (version: 8.0.6)

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 "babel-loader" 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\07\node_modules\babel-loader is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

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

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!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! matchstatz@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the matchstatz@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\07\AppData\Roaming\npm-cache\_logs\2020-06-03T18_01_06_704Z-debug.log

debug log调试日志

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.17.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle matchstatz@0.1.0~prestart: matchstatz@0.1.0
6 info lifecycle matchstatz@0.1.0~start: matchstatz@0.1.0
7 verbose lifecycle matchstatz@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle matchstatz@0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\07\OneDrive\Desktop\matchstatztask\matchstatz\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk-12.0.2\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Users\07\.windows-build-tools\python27\;C:\Users\07\AppData\Local\Microsoft\WindowsApps;C:\Users\07\AppData\Local\GitHubDesktop\bin;C:\Users\07\AppData\Roaming\npm
9 verbose lifecycle matchstatz@0.1.0~start: CWD: C:\Users\07\OneDrive\Desktop\matchstatztask\matchstatz
10 silly lifecycle matchstatz@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle matchstatz@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle matchstatz@0.1.0~start: Failed to exec start script
13 verbose stack Error: matchstatz@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid matchstatz@0.1.0
15 verbose cwd C:\Users\07\OneDrive\Desktop\matchstatztask\matchstatz
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.17.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error matchstatz@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the matchstatz@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 ]

**Here in above details, i've created reactjs app using npx create-react-app appname but after getting into directory using cd command, if I give npm start means I'm getting this kind of errors. **在上面的详细信息中,我使用 npx create-react-app appname 创建了 reactjs 应用程序,但是在使用 cd 命令进入目录后,如果我给 npm 启动意味着我遇到了这种错误。 I have pasted the debug log and Terminal error here.我在这里粘贴了调试日志和终端错误。 And getting error details as "There 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."并获取错误详细信息为“项目依赖关系树可能存在问题。这可能不是 Create React App 中的错误,而是您需要在本地修复的问题。” ** **

You should remove /Users/nameOfYourComputer/node_modules, as this seems to be your root directory and you generally shouldn't have node_modules there.您应该删除 /Users/nameOfYourComputer/node_modules,因为这似乎是您的根目录,并且您通常不应该在那里有 node_modules。

It's been one day, I'm trying to figure it out, I tried the above instructions but nothing until I found this solution in reddit.已经有一天了,我试图弄清楚,我尝试了上面的说明,但是直到我在 reddit 中找到了这个解决方案。

Sometime back i faced the same issue and I followed the same steps as mention below.有时我遇到了同样的问题,我遵循了与下面提到的相同的步骤。

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.删除项目文件夹中的 package-lock.json(不是 package.json。)和/或 yarn.lock。
  2. Delete node_modules in your project folder.删除项目文件夹中的 node_modules。
  3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中 package.json 文件中的依赖项和/或 devDependencies 中删除“babel-loader”。
  4. Run npm install or yarn, depending on the package manager you use.运行 npm install 或 yarn,具体取决于您使用的 package 管理器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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