title: use npm package in Angular 2 component
body: <p>I would like to use an available npm package in my Angular 4 component but am struggling to make it work.  The package is called 'ip' available from <a href="https://www.npmjs.com/package/ip" rel="nofollow noreferrer">https://www.npmjs.com/package/ip</a></p>
  <p>I have added the package as follows:</p>
  <blockquote>
  <p>npm install ip --save</p>
  <p>npm install --save @types/ip</p>
  </blockquote>
  <p>and in my app.module.ts I have:</p>
  <pre><code>import { isV4Format } from 'ip';
  </code></pre>
  <p>and I add isV4Format to the imports list in app.module.ts</p>
  <p>I then try to use the ip package it in my class as follows:</p>
  <pre><code>import { isV4Format } from 'ip';
  
  export class TabValidator {
      private static _check(address: string): any {
          const ip = require('ip');
          if (!myip.isV4Format(address)) { return { 'wrongFormat': true }; }
          return null;
      }
  }
  </code></pre>
  <p>The compiler complains about the component:</p>
  <blockquote>
  <p>Cannot find name 'require'</p>
  </blockquote>
  <p>and about app.module.ts:</p>
  <blockquote>
  <p>Argument of type '{ declarations: (typeof InterfacesComponent | typeof EditnicComponent | typeof AppComponent)[]; i...' is not assignable to parameter of type 'NgModule'.</p>
  </blockquote>
  <p>Can someone tell me what's wrong with the above?  I suspect there are a few things wrong.  I found 2 similar question on SO but they appear to be for different angular versions.</p>