Q:

Fail to install package - ionic-native

I am following this link to install local-notification into my ionic 2 app. 
First I ran following two commands
Username@DESKTOP-BNKQVBC MINGW64 ~/Reminder-App (platform-specific)
$ npm install ionic-native --save
rxjs@5.0.1 node_modules\ionic-native\node_modules\rxjs -> node_modules\@ionic\cloud\node_modules\rxjs
ionic-hello-world@0.0.0 C:\Users\Username\Reminder-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_modules\chokidar\node_modules\fsevents):
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:\Users\Username\Reminder-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_modules\chokidar\node_modules\fsevents):
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. 

After that I try to run following command
npm install --save @ionic-native/local-notifications

But it gave me following warnings
Username@DESKTOP-BNKQVBC MINGW64 ~/Reminder-App (platform-specific)
$ npm install --save -g @ionic-native/local-notifications
C:\Users\Username\AppData\Roaming\npm
`-- @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. 

But I already have installed these dependencies 
"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"
  }

Can anyone guide me that what am I missing ? 

A:

Check out npm documentation. 

1) It was due to that the packages were not installed globally ?  

Yes.  More accurately, npm did not find the required peer dependencies for @ionic-native/local-notifications in the global node_modules folder which is why it gave the warning even if the packages were present in your local project. 

2) Can you let me know when to use -g and when not to ? 

This depends on whether you need certain packages for development of multiple projects instead of a specific one especially those whichcan be run in command line .  Packages like typescript,ionic(the cli) are installed globally. 
According to the documentation:

If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally.  On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally. 

Your command needs to be :
npm install --save @ionic-native/local-notifications

without the -g.