gpt4 book ai didi

npm 安装的版本与 package.json 中指定的版本不同,这怎么可能?如何解决这个问题?

转载 作者:行者123 更新时间:2023-12-04 02:07:03 26 4
gpt4 key购买 nike

如果我使用 package.json下面给出执行 npm install然后将安装 react-15.4.2 (请参阅下面的 npm ls)即使我指定了版本 15.3.2 .

这怎么可能 ?

为什么会这样?

我怎样才能避免这种情况?
package.json的内容:

{
"name": "sbt-demo",
"version": "0.1.0",
"description": "Webpack configuration for sbt-demo",
"license": "GPL-3.0",
"scripts": {
"build": "webpack --config webpack.config.prod.js",
"dist": "webpack --config webpack.config.prod.js"
},
"devDependencies": {
"compression-webpack-plugin": "^0.2.0",
"css-loader": "^0.23.0",
"file-loader": "^0.8.4",
"ghooks": "^1.3.2",
"gulp-decompress": "^1.1.0",
"image-webpack-loader": "^1.6.1",
"imagemin": "^4.0.0",
"lodash": "^4.14.1",
"node-libs-browser": "^0.5.2",
"react-hot-loader": "^1.2.7",
"style-loader": "^0.13.0",
"url-loader": "^0.5.6",
"webpack": "^1.9.10",
"webpack-dev-server": "^1.9.0"
},
"dependencies": {
"highlight.js": "8.9.1",
"material-ui": "^0.15.2",
"react": "^15.3.2",
"react-addons-create-fragment": "15.3.2",
"react-addons-css-transition-group": "15.3.2",
"react-addons-pure-render-mixin": "15.3.2",
"react-addons-transition-group": "15.3.2",
"react-addons-update": "15.3.2",
"react-dom": "^15.3.2",
"react-geomicons": "^2.0.4",
"react-grid-layout": "^0.13.9",
"react-infinite": "^0.7.1",
"react-select": "^1.0.0-beta",
"react-sortable-hoc": "^0.2.0",
"react-spinner": "^0.2.3",
"react-tagsinput": "^3.0.3",
"react-tap-event-plugin": "^1.0.0",
"svg-loader": "0.0.2"
}
}
npm ls给出:
├─┬ react@15.4.2
│ ├─┬ fbjs@0.8.9
│ │ ├── core-js@1.2.7
│ │ ├─┬ isomorphic-fetch@2.2.1
│ │ │ ├─┬ node-fetch@1.6.3
│ │ │ │ └─┬ encoding@0.1.12
│ │ │ │ └── iconv-lite@0.4.15
│ │ │ └── whatwg-fetch@2.0.2
│ │ ├─┬ promise@7.1.1
│ │ │ └── asap@2.0.5
│ │ ├── setimmediate@1.0.5
│ │ └── ua-parser-js@0.7.12
│ └─┬ loose-envify@1.3.1
│ └── js-tokens@3.0.1
├── react-addons-create-fragment@15.3.2
├── react-addons-css-transition-group@15.3.2
├── react-addons-pure-render-mixin@15.3.2
├── react-addons-transition-group@15.3.2
├── react-addons-update@15.3.2
├── react-dom@15.4.2
├─┬ react-geomicons@2.1.0
│ └── geomicons-open@3.0.0-beta.2
├─┬ react-grid-layout@0.13.9
│ ├── lodash.isequal@4.5.0
│ ├── react-draggable@2.2.3
│ └── react-resizable@1.6.0
├─┬ react-hot-loader@1.3.1
│ ├── react-hot-api@0.4.7
│ └─┬ source-map@0.4.4
│ └── amdefine@1.0.1
├─┬ react-infinite@0.7.3
│ ├── lodash.isarray@3.0.4
│ ├── lodash.isfinite@3.2.0
│ ├── object-assign@4.0.1
│ ├─┬ react@0.14.8
│ │ ├─┬ envify@3.4.1
│ │ │ ├─┬ jstransform@11.0.3
│ │ │ │ ├── base62@1.1.2
│ │ │ │ ├─┬ commoner@0.10.8
│ │ │ │ │ ├── detective@4.3.2
│ │ │ │ │ ├── private@0.1.7
│ │ │ │ │ └─┬ recast@0.11.22
│ │ │ │ │ ├── ast-types@0.9.5
│ │ │ │ │ ├── esprima@3.1.3
│ │ │ │ │ └── source-map@0.5.6
│ │ │ │ ├── esprima-fb@15001.1.0-dev-harmony-fb
│ │ │ │ └── object-assign@2.1.1

最佳答案

既然你给了 "react"一个脱字符号 "react": "^15.3.2"它将始终获取低于 16.0.0 的最新版本。

要获得 react 的确切版本,请删除版本 "react": "15.3.2" 之前的插入符号.

但是通过这样做,您必须手动检查/更改使用 react 的其他依赖项的版本依赖项。因为它们可能与您指定的 react 版本不兼容。

官方文档请引用 https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004 .

关于npm 安装的版本与 package.json 中指定的版本不同,这怎么可能?如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42470586/

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