无法安装软件包 - 离子原生



我正在点击此链接将本地通知安装到我的 ionic 2 应用程序中。

首先我运行了两个命令

Username@DESKTOP-BNKQVBC MINGW64 ~/Reminder-App (platform-specific)
$ npm install ionic-native --save
rxjs@5.0.1 node_modulesionic-nativenode_modulesrxjs -> node_modules@ioniccloudnode_modulesrxjs
ionic-hello-world@0.0.0 C:UsersUsernameReminder-App
+-- @ionic/cloud-angular@0.12.0
| `-- @ionic/cloud@0.16.0
|   `-- ionic-native@2.9.0
`-- ionic-native@3.5.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_moduleschokidarnode_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @ionic-native/background-mode@3.6.1 requires a peer of @ionic-native/core@^3.6.0 but none was installed.
npm WARN The package @ionic/cloud-angular is included as both a dev and production dependency.
Username@DESKTOP-BNKQVBC MINGW64 ~/Reminder-App (platform-specific)
$ npm install
ionic-hello-world@0.0.0 C:UsersUsernameReminder-App
+-- @ionic-native/core@3.8.0
+-- @ionic-native/splash-screen@3.6.0
`-- @ionic-native/status-bar@3.6.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_moduleschokidarnode_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN The package @ionic/cloud-angular is included as both a dev and production dependency.

之后我尝试运行以下命令

npm install --save @ionic-native/local-notifications

但它给了我以下警告

Username@DESKTOP-BNKQVBC MINGW64 ~/Reminder-App (platform-specific)
$ npm install --save -g @ionic-native/local-notifications
C:UsersUsernameAppDataRoamingnpm
`-- @ionic-native/local-notifications@3.8.0
npm WARN @ionic-native/local-notifications@3.8.0 requires a peer of @ionic-native/core@^3.6.0 but none was installed.
npm WARN @ionic-native/local-notifications@3.8.0 requires a peer of @angular/core@* but none was installed.
npm WARN @ionic-native/local-notifications@3.8.0 requires a peer of rxjs@^5.0.1 but none was installed.

但是我已经安装了这些依赖项

"dependencies": {
"@angular/common": "4.0.2",
"@angular/compiler": "4.0.2",
"@angular/compiler-cli": "4.0.2",
"@angular/core": "4.0.2",
"@angular/forms": "4.0.2",
"@angular/http": "4.0.2",
"@angular/platform-browser": "4.0.2",
"@angular/platform-browser-dynamic": "4.0.2",
"@ionic-native/background-mode": "^3.6.1",
"@ionic-native/core": "^3.6.0",
"@ionic-native/splash-screen": "3.6.0",
"@ionic-native/status-bar": "3.6.0",
"@ionic/cloud-angular": "^0.12.0",
"@ionic/storage": "^2.0.1",
"ionic-angular": "3.1.0",
"ionic-native": "^3.5.0",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.5"
}

谁能指导我我错过了什么?

查看 npm 文档。

1)这是由于软件包没有全局安装?

是的。更准确地说,npm 在全局node_modules文件夹中找不到@ionic-native/local-notifications所需的对等依赖项,这就是为什么即使本地项目中存在包,它也会发出警告的原因。

2)你能告诉我什么时候使用-g,什么时候不使用吗?

这取决于您是否需要某些包来开发多个项目而不是特定的包,尤其是那些可以在命令行中运行的包。像typescriptionic(cli)这样的软件包是全局安装的。

根据文档:

如果您想将其用作命令行工具,例如 grunt CLI,那么您希望全局安装它。另一方面,如果你想使用类似 Node 的要求来依赖你自己的模块中的包,那么你需要在本地安装。

您的命令需要:

npm install --save @ionic-native/local-notifications

没有-g.

相关内容

  • 没有找到相关文章

最新更新