我的package.json
看起来像这样
{
"name": "hello-world",
"version": "1.0.0",
"description": "The Hello World",
"author": "",
"license": "MIT",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"dependencies": {
"@angular/common": "~2.0.1",
"@angular/compiler": "~2.0.1",
"@angular/core": "~2.0.1",
"@angular/http": "~2.0.1",
"@angular/platform-browser": "~2.0.1",
"@angular/platform-browser-dynamic": "~2.0.1",
"@angular/router": "~3.0.1",
"@angular/upgrade": "~2.0.1",
"systemjs": "0.19.39",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25",
"angular-in-memory-web-api": "~0.1.1",
"bootstrap": "4.0.0-alpha.4"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings": "^1.4.0"
}
}
当我运行npm i
时,它运行成功,但我收到了一些警告。
npm WARN angular-in-memory-web-api@0.1.17 requires a peer of rxjs@5.0.0-rc.4 but none was installed.
npm WARN angular-in-memory-web-api@0.1.17 requires a peer of zone.js@^0.7.2 but none was installed.
我将这些行添加到package.json
"peerDependencies": {
"rxjs": "5.0.0-rc.4",
"zone.js": "^0.7.2"
}
但是当我再次运行npm i
时,我仍然会收到此警告
npm WARN hello-world@1.0.0 requires a peer of rxjs@5.0.0-rc.4 but none was installed.
npm WARN hello-world@1.0.0 requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN angular-in-memory-web-api@0.1.17 requires a peer of rxjs@5.0.0-rc.4 but none was installed.
npm WARN angular-in-memory-web-api@0.1.17 requires a peer of zone.js@^0.7.2 but none was installed.
主要应用程序的附加警告。
为什么会这样,以及如何摆脱这种警告?
答案 0 :(得分:0)
删除node_modules
文件夹并运行npm install
。错误会消失。
答案 1 :(得分:0)
TL; DR
Peer Dependencies (对等依赖项)是一种特殊的依赖项,它们被不直接调用它们的包所使用,从而为用户(您)提供了控制权。因此,您必须手动安装这些软件包。
您不需要将if (editTxt.getText().toString().startsWith("http://"){
webv.loadUrl(editTxt.getText().toString());
}else{
webv.loadUrl("http://" + editTxt.getText().toString());
}
添加到peerDependencies
中。
您看到这些错误的原因是,您的某些依赖项在其package.json
中将rxjs@5.0.0-rc.4
和zone.js@^0.7.2
声明为package.json
。这就是为什么在peerDependencies
中添加peerDependencies
时会两次收到这些警告的原因。
要了解有关对等依赖项的更多信息,建议阅读以下内容: