本文介绍了“npm 安装"给出错误信息“无效",它是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请检查图片.

我猜它与 package.json 有关,但我不太确定.

I guess it's related to package.json but am not very sure.

回复评论以获取更多信息

最初我是在安装 material-ui.

详细信息在这里:

I:\react-boilerplate>npm install material-ui

[email protected] I:\react-boilerplate

[email protected] I:\react-boilerplate

+-- [email protected]

+-- [email protected]

|+-- 键码@2.1.8

| +-- [email protected]

|+-- [email protected]

| +-- [email protected]

|+-- 未满足对等依赖反应@^15.4.2

| +-- UNMET PEER DEPENDENCY react@^15.4.2

|+-- [email protected]

| +-- [email protected]

|+-- [email protected]

| +-- [email protected]

|+-- [email protected]

| +-- [email protected]

||+-- 未满足对等依赖反应@^15.4.2

| | +-- UNMET PEER DEPENDENCY react@^15.4.2

||`[email protected]

| | `-- [email protected]

|+-- [email protected]

| +-- [email protected]

||`--更改发射器@0.1.3

| | `-- [email protected]

|`-- [email protected]

| `-- [email protected]

+-- 未满足对等依赖 react-tap-event-plugin@^2.0.1

+-- UNMET PEER DEPENDENCY react-tap-event-plugin@^2.0.1

`-- 未满足对等依赖 [email protected]

`-- UNMET PEER DEPENDENCY [email protected]

然后我试图通过 npm install 他们来修复 UNMET PEER DEPENDENCY.

Then I was trying to fix the UNMET PEER DEPENDENCY by npm install them.

第一次尝试给出了这个:

The first attempt gives this:

[email protected] I:\react-boilerplate

+-- [email protected] 无效

+-- [email protected] invalid

+-- [email protected]

+-- [email protected]

`-- 未满足对等依赖 [email protected]

`-- UNMET PEER DEPENDENCY [email protected]

`-- [email protected]

`-- [email protected]

如您所见,这是我遇到的第一个 invalid.

As you can see this is the first invalid I met.

所以我只是想弄清楚为什么会弹出这个 invalid 以及如何修复它.

So I'm just trying to figure out why this invalid pops out and how to fix it.

回复评论以获取更多信息

这里是 package.json,依赖部分

Here is the package.json, dependencies section

依赖关系":{"babel-polyfill": "6.20.0","粉笔": "1.1.3",压缩":1.6.2","cross-env": "3.1.3","express": "4.14.0","fontfaceobserver": "2.0.7","不可变": "3.8.1",国际":1.2.5",不变":2.2.2","ip": "1.1.4","lodash": "4.17.2","极简主义": "1.2.0",反应":15.4.1","react-dom": "15.4.1",反应头盔":3.2.2",反应国际":2.1.5","react-redux": "4.4.6",反应路由器":3.0.0","react-router-redux": "4.0.6",反应路由器滚动":0.4.1","redux": "3.6.0","redux-immutable": "3.0.8","redux-saga": "0.14.0","重新选择": "2.5.4","sanitize.css": "4.1.0","样式组件": "1.1.2","警告": "3.0.0","whatwg-fetch": "2.0.1" },

和 devDependencies 部分

and the devDependencies section

"devDependencies": {"babel-cli": "6.18.0","babel-core": "6.21.0","babel-eslint": "7.1.1","babel-loader": "6.2.10","babel-plugin-dynamic-import-node": "1.0.0","babel-plugin-react-intl": "2.2.0","babel-plugin-react-transform": "2.0.2","babel-plugin-transform-es2015-modules-commonjs": "6.18.0","babel-plugin-transform-react-constant-elements": "6.9.1","babel-plugin-transform-react-inline-elements": "6.8.0","babel-plugin-transform-react-remove-prop-types": "0.2.11","babel-preset-latest": "6.16.0","babel-preset-react": "6.16.0","babel-preset-react-hmre": "1.1.1","babel-preset-stage-0": "6.16.0","cheerio": "0.22.0","循环依赖插件": "2.0.0","工作服": "2.11.15","css-loader": "0.26.1","酶": "2.6.0","eslint": "3.11.1","eslint-config-airbnb": "13.0.0","eslint-config-airbnb-base": "10.0.1","eslint-import-resolver-webpack": "0.8.0","eslint-plugin-import": "2.2.0","eslint-plugin-jsx-a11y": "2.2.3","eslint-plugin-react": "6.7.1","eslint-plugin-redux-saga": "0.1.5","eventsource-polyfill": "0.9.6","exports-loader": "0.6.3",文件加载器":0.9.0","html-loader": "0.4.4","html-webpack-plugin": "2.24.1","image-webpack-loader": "2.0.0",进口装载机":0.6.5","jest-cli": "18.0.0","lint-staged": "3.2.1","ngrok": "2.2.4",节点扑通":0.5.4",空加载器":0.1.1","离线插件": "4.5.2","扑通": "1.7.3",预提交":1.1.3","react-addons-test-utils": "15.4.1","rimraf": "2.5.4","shelljs": "0.7.5","sinon": "2.0.0-pre",样式加载器":0.13.1","url-loader": "0.5.7","webpack": "2.2.0-rc.3","webpack-dev-middleware": "1.9.0","webpack-hot-middleware": "2.15.0" }

推荐答案

此处的无效依赖项表明安装了不适当版本的依赖项包.在这种情况下,您的项目正在请求 [email protected],但安装的是 2.2.1 版本.请注意,版本范围内没有插入符号 (^) 或波浪号 (~),这意味着 2.2.1 不是有效匹配.

An invalid dependency here suggests that an inappropriate version of a dependency package was installed. In this case, your project is requesting [email protected], but version 2.2.1 was installed instead. Note that there is no caret (^) or tilde (~) in the version range, which means that 2.2.1 is not a valid match.

React 发生了另一个冲突,在版本 15.4.1 中已修复,应根据其他依赖项的要求升级到版本范围 ^15.4.2 (比如material-ui).

Another conflict happens with React, which is fixed at version 15.4.1 and should be upgraded to the version range ^15.4.2, as required by other dependencies (such as material-ui).

为了设置依赖项的新版本(升级/降级),不要忘记相应的保存标志(--save/-S--save-dev/-D).

In order to set a new version of a dependency (to upgrade/downgrade it), don't forget the respective save flag (--save/-S or --save-dev/-D).

npm install -S react@^15.4.2

不幸的是,react-tap-event-plugin 依赖于版本 2.2.0-rc3 webpack,所以你不应该升级 webpack.相反,您可以调用 npm update --dev 以确保所有注册的依赖项都安装了正确的版本.如果一切都失败了,一个简单但有效的技巧是删除 node_modules 文件夹并从头开始安装所有软件包.

Unfortunately, react-tap-event-plugin depends on version 2.2.0-rc3 webpack, so you should not upgrade webpack. Instead, you can call npm update --dev to make sure that all registered dependencies are installed with the right versions. If all else fails, a naive but effective trick is to remove the node_modules folder and install all packages from scratch.

这篇关于“npm 安装"给出错误信息“无效",它是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 08:29