How to structure a shared npm module for Angular 2/Ionic 2 apps


#1

I am developing several Ionic 2 utility apps that share functionaility such as authentication services and keypad components and naturally want to separate these out into a shared module.

The plan has been to use npm link to ease concurrent development of the shared module and the apps. However, I have run into issues when trying to build and run my Ionic app which could either be due to improper structure of my shared module or build tool config.

Essentially I get one of the the two following error messages depending on whether my shared module is using forRootr():

Error: Unexpected value '[object Object]' imported by the module 'AppModule'

or

Unexpected value 'Appkit' imported by the module 'AppModule'

I have a more detailed write up of the issue over in this stack overflow question.

Does anyone have experience with a npm component library in Ionic 2 RC1

Your system information:

Cordova CLI: 6.4.0
Gulp version:  CLI version 1.2.2
Gulp local:
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
Ionic App Scripts Version: 0.0.38
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.7.0
Xcode version: Xcode 8.0 Build version 8A218a

#2

Fighting with the very same problem for more than month so far with no luck. Tried reaching Ionic guys multiple times but they keep doing the ping-pong game, no official examples or guides since beta.


#3

Yeah, I must admit its been quite frustrating. I have looked at a lot of other 3rd party libraries that are meant to work fine with the Ionic 2 RC and they appear to be no different to what I have done.


#4

I am running into the same problem and have been researching it for a few days now without any luck. It does not seem to be limited to Ionic.

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.2
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
Ionic App Scripts Version: 0.0.43
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.13
Node Version: v5.6.0
Xcode version: Not installed