Skip to content

How to import/require a npm module #8274

@glaucocustodio

Description

@glaucocustodio

Short description of the problem:

I have an app running at 2.0.0-beta.11 version and now I am migrating to 2.0.0-rc.0.

I am importing my installed modules like PouchDB (that was installed via npm installl pouchdb) through let PouchDB = require('pouchdb'); however the same code does not work on the rc version, I just get require is not defined (I already have typings installed).

I know a lot of changes were made from a version to another (Angular 2.0 final, TypeScript 2) etc and I would like to know how I should proceed now.

I read that on TS 2 I should import using the new ES syntax like import * as PouchDB from 'pouchdb' but this way (and alternatives) I just get Cannot find module 'pouchdb'.

Thank you for the great work, you are amazing.

What behavior are you expecting?

Be able to import a npm module installed at node_modules.

Steps to reproduce:

  1. Start a brand new ionic 2 rc app
  2. Install any npm module
  3. Try to import it

Which Ionic Version? 2.x

Run ionic info from terminal/cmd prompt: (paste output below)

Cordova CLI: Not installed
Gulp version: CLI version 1.2.2
Gulp local:
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X Yosemite
Node Version: v5.2.0
Xcode version: Xcode 7.2 Build version 7C68

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions