简体   繁体   English

我遇到了 npm 问题,当我运行“npm install”时我不明白

[英]I am having npm issues I do not understand when I run `npm install`

When I run npm install I get the following error below and I don't have an idea how I could fix it.当我运行npm install时,我收到以下错误,我不知道如何修复它。 I tried digging into that error log to resolve those dependencies but all not no avail.我尝试深入研究该错误日志以解决这些依赖关系,但都无济于事。 I will appreciate any lead to resolve this problem.我将不胜感激任何解决此问题的线索。 It is my React first code.这是我的 React 第一个代码。 Thanks in anticipation!感谢期待!

Error Log错误日志

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: @babel/core@7.2.2
npm ERR! node_modules/@babel/core
npm ERR!   @babel/core@"7.2.2" from react-scripts@2.1.8
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"^2.1.3" from the root project
npm ERR!     peer react-scripts@">=2.1.3" from react-app-rewired@2.1.8
npm ERR!     node_modules/react-app-rewired
npm ERR!       react-app-rewired@"^2.1.0" from the root project
npm ERR!   @babel/core@"^7.1.6" from @svgr/webpack@4.1.0
npm ERR!   node_modules/@svgr/webpack
npm ERR!     @svgr/webpack@"4.1.0" from react-scripts@2.1.8
npm ERR!     node_modules/react-scripts
npm ERR!       react-scripts@"^2.1.3" from the root project
npm ERR!       1 more (react-app-rewired)
npm ERR!   8 more (babel-core, babel-loader, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @babel/core@"^7.13.0" from @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.13.12
npm ERR! node_modules/@babel/preset-env/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
npm ERR!   @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@"^7.13.12" from @babel/preset-env@7.14.1
npm ERR!   node_modules/@babel/preset-env
npm ERR!     @babel/preset-env@"^7.1.6" from @svgr/webpack@4.1.0
npm ERR!     node_modules/@svgr/webpack
npm ERR!       @svgr/webpack@"4.1.0" from react-scripts@2.1.8
npm ERR!       node_modules/react-scripts
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/tiwa/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tiwa/.npm/_logs/2021-05-11T18_39_17_361Z-debug.log

package.json package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.0.0",
    "eslint": "^6.0.1",
    "ipfs-api": "^26.1.2",
    "json-loader": "^0.5.7",
    "node-sass": "^4.11.0",
    "react": "^16.8.6",
    "react-app-rewired": "^2.1.0",
    "react-bootstrap": "^1.0.0-beta.5",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.0",
    "react-scripts": "^2.1.3",
    "react-toggle": "^4.0.2",
    "rimble-ui": "^0.7.0",
    "styled-components": "^4.1.3",
    "web3": "1.0.0-beta.37",
    "zeppelin-solidity-hot-loader": "^1.2.3"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {}
}

npm version npm版

7.0.8

node version节点版本

v15.2.1

Log File日志文件

GNU nano 2.0.6                                                 
File: /Users/tiwa/.npm/_logs/2021-05-12T10_58_57_849Z-debug.log                                                                                                          

0 verbose cli [
0 verbose cli   '/Users/tiwa/.asdf/installs/nodejs/15.2.1/bin/node',
0 verbose cli   '/Users/tiwa/.asdf/installs/nodejs/15.2.1/bin/npm',
0 verbose cli   'run',
0 verbose cli   'client'
0 verbose cli ]
1 info using npm@7.0.8
2 info using node@v15.2.1
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/Users/tiwa/.asdf/installs/nodejs/15.2.1/lib/node_modules/npm/npmrc Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/tiwa/WebstormProjects/nft/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/Users/tiwa/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/Users/tiwa/.asdf/installs/nodejs/15.2.1/.npm/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 3ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 13ms
19 verbose npm-session ed61a70477c00f22
20 timing npm:load Completed in 23ms
21 timing command:run-script Completed in 34358ms
22 verbose stack Error: command failed
22 verbose stack     at ChildProcess.<anonymous> (/Users/tiwa/.asdf/installs/nodejs/15.2.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
22 verbose stack     at ChildProcess.emit (node:events:329:20)
22 verbose stack     at maybeClose (node:internal/child_process:1055:16)
22 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5)
23 verbose pkgid NFT-based-photo-marketplace@1.0.0
24 verbose cwd /Users/tiwa/WebstormProjects/nft
25 verbose Darwin 20.3.0
26 verbose argv "/Users/tiwa/.asdf/installs/nodejs/15.2.1/bin/node" "/Users/tiwa/.asdf/installs/nodejs/15.2.1/bin/npm" "run" "client"
27 verbose node v15.2.1
28 verbose npm  v7.0.8
29 error code 1
30 error path /Users/tiwa/WebstormProjects/nft
31 error command failed
32 error command sh -c cd client && npm run start

Have you tried removing node_modules/ and package-lock.js and then run npm install command?您是否尝试过删除node_modules/package-lock.js然后运行npm install命令?

npm 7 requires peer dependencies to be installed when most React projects still declare this as optional. npm 7 需要在大多数 React 项目仍将其声明为可选时安装对等依赖项。

You can install using npm i --legacy-peer-deps or set this in your .npmrc :您可以使用npm i --legacy-peer-deps安装或在.npmrc中设置:

npm set config legacy-peer-deps=true

are you sure, you are doing npm install in the correct folder?你确定,你在正确的文件夹中安装 npm 吗? First cd into the correct folder in the terminal where you need to install and then run below command -首先 cd 进入终端中需要安装的正确文件夹,然后运行以下命令 -

npm ci

Generally, I've found that yarn provides better info than npm in case of an error.一般来说,我发现在出现错误的情况下,纱线提供的信息比 npm 更好。 Could you possibly share a (gist) link to /Users/tiwa/.npm/_logs/2021-05-11T18_39_17_361Z-debug.log?您能否分享指向 /Users/tiwa/.npm/_logs/2021-05-11T18_39_17_361Z-debug.log 的(要点)链接?

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

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