gpt4 book ai didi

node.js - NPM 需要一个对等点,但所有对等点都在 package.json 和 node_modules 中

转载 作者:太空宇宙 更新时间:2023-11-03 23:23:58 26 4
gpt4 key购买 nike

我面临安装时 npm 所说的问题

npm WARN eslint-config-react-app@2.0.1 requires a peer of babel-eslint@^7.2.3 but none was installed.
npm WARN eslint-config-react-app@2.0.1 requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none was installed.
npm WARN semantic-ui-react@0.74.2 requires a peer of react@>=0.14.0 <= 15 but none was installed.
npm WARN semantic-ui-react@0.74.2 requires a peer of react-dom@>=0.14.0 <= 15 but none was installed.

我认为非常奇怪的是,我的 package.json 中实际上有这些依赖项,并且还在 node_modules 文件夹中看到它们。

我的package.json:

{
"name": "react-box",
"version": "0.1.0",
"private": true,
"devDependencies": {
"autoprefixer": "7.1.4",
"babel-core": "6.26.0",
"babel-eslint": "^8.0.1",
"babel-jest": "21.2.0",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.0.3",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "2.1.0",
"connect-history-api-fallback": "1.3.0",
"cross-spawn": "5.1.0",
"css-loader": "0.28.7",
"detect-port": "1.2.1",
"dotenv": "4.0.0",
"eslint": "4.8.0",
"eslint-config-react-app": "^2.0.1",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.38.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.1",
"file-loader": "1.1.5",
"filesize": "3.5.10",
"fs-extra": "4.0.2",
"gzip-size": "4.0.0",
"html-webpack-plugin": "2.30.1",
"http-proxy-middleware": "0.17.4",
"jest": "21.2.1",
"json-loader": "0.5.7",
"object-assign": "4.1.1",
"path-exists": "3.0.0",
"postcss-loader": "2.0.6",
"promise": "8.0.1",
"react-dev-utils": "^4.1.0",
"recursive-readdir": "2.2.1",
"strip-ansi": "4.0.0",
"style-loader": "0.19.0",
"truffle-contract": "^3.0.0",
"truffle-solidity-loader": "0.0.8",
"url-loader": "0.6.2",
"webpack": "3.6.0",
"webpack-dev-server": "2.9.1",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
},
"dependencies": {
"axios": "^0.16.2",
"babel-eslint": "^8.0.1",
"dotenv": "^2.0.0",
"react": "^16.0.0",
"react-countup": "^2.2.0",
"react-dom": "^16.0.0",
"semantic-ui-react": "^0.74.2"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.js?(x)",
"<rootDir>/src/**/?(*.)(spec|test).js?(x)"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx"
]
},
"babel": {
"presets": [
"react-app"
]
},
"eslintConfig": {
"extends": "react-app"
}
}

当尝试像这样手动安装这些对等点时:

npm install babel-eslint --save-dev

我仍然收到错误:

├── UNMET PEER DEPENDENCY babel-eslint@8.0.1
├── UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@6.0.2
├── UNMET PEER DEPENDENCY react@16.0.0
└── UNMET PEER DEPENDENCY react-dom@16.0.0

也许我不明白 NPM 是如何工作的,但据我了解,手动安装至少应该可以解决它,对吗?

如果有人需要更多信息,请发表评论,我将提供附加信息。谢谢!

最佳答案

关于peerDeps版本不匹配的NPM警告在这里是正确的。这些软件包已安装,但您拥有的某些其他软件包不支持已安装的版本。

就您而言 - 它们太新了,这意味着警告包的维护者尚未更新到这些版本。并将所需的peerDeps版本限制在API兼容范围内(没有破坏/主要版本飞跃)。

eslint-config-react-app@2.0.1 需要对等 deps:babel-eslint@^7.2.3(即 7.x.x)和 eslint-plugin-jsx-a11y@^5.1.1(即 5.x.x)。

您的版本是 "babel-eslint": "^8.0.1""eslint-plugin-jsx-a11y": "^6.0.2"。第一个数字 - 主要 - 不匹配。这就是 ^(插入符号)标记的含义。

semantic-ui-react相同 - 他们还不支持react@16(🤗我也等不及了!)。

在此之前,您可以安装具有确切主要版本的软件包:

> npm view babel-eslint@7.* version // list released versions in required range 7.x.x
babel-eslint@7.0.0 '7.0.0'
babel-eslint@7.1.0 '7.1.0'
babel-eslint@7.1.1 '7.1.1'
babel-eslint@7.2.0 '7.2.0'
babel-eslint@7.2.1 '7.2.1'
babel-eslint@7.2.2 '7.2.2'
babel-eslint@7.2.3 '7.2.3'
> npm install --save-dev babel-eslint@7.2.3 // install latest version in required range

与其他包相同。

PS:另外,在 package.json 中,您必须删除重复的记录:dependency 中的 babel-eslintdotenv,因为它们已经在 devDependency 中声明。

关于node.js - NPM 需要一个对等点,但所有对等点都在 package.json 和 node_modules 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46602286/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com