ionic-framework: Ionic2 RC.0: Module does not export ModuleClass error

After installing the module using:

npm install --save angular2-moment

And adding it to NgModule:

import { MomentModule } from 'angular2-moment';

@NgModule({
  ...
  imports: [MomentModule]
})

And import/use in my component, I am getting this error when serving:

[17:37:53]  Error: Module c:\dev\app\node_modules\angular2-moment\index.js does not export MomentModule (imported by c:\dev\app\.tmp\app\app.module.js)
    at Module.trace (rollup.js:7677:29)
    at ModuleScope.findDeclaration (rollup.js:7300:22)
    at Scope.findDeclaration (rollup.js:5351:39)
    at Identifier.bind (rollup.js:6489:29)
    at rollup.js:5151:50
    at ArrayExpression.eachChild (rollup.js:5165:19)
    at ArrayExpression.bind (rollup.js:5151:7)
    at rollup.js:5151:50
    at Node.eachChild (rollup.js:5168:5)
    at Node.bind (rollup.js:5151:7)

The same occurs when I try to import and use other modules.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 11
  • Comments: 23 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@lathonez After three days of changing every possible config string I gave up with RC and went back to beta. I think this time guys went too far in locking the build tools into a separate library, besides trying to fix the build tools (that were improperly tested prior to release) the community will have struggle with customizations and the need building full vertical of build tools and configs from scratch. Changing “node_modules@ionic\something” does not scale at all. Locked in configs are fine for end applications, not for project templates and frameworks. Anyway, being very disappointed with the direction Ionic team took and waiting for either fixes or community solutions based on non-Rollup configs.

How can we disable the rollup until this issue is not fixed?

You can use this workaround: edit file node_modules/@ionic/app-scripts/config/rollup.config.js

  • add useStrict: false to the module.exportsobject
  • add'node_modules/angular2-moment/**'and 'node_modules/angular2-moment/index.js' : ['MomentModule']like this
    commonjs(
        {
          include: [
            'node_modules/rxjs/**',
            'node_modules/angularfire2/**',
            'node_modules/firebase/**',
            'node_modules/angular2-moment/**'
          ],
          namedExports: {
            'node_modules/angularfire2/node_modules/firebase/firebase.js': ['initializeApp', 'auth', 'database'],
            'node_modules/angularfire2/node_modules/firebase/firebase-browser.js': ['initializeApp', 'auth', 'database'],
            'node_modules/angular2-moment/index.js' : ['MomentModule']

          }
        }),

Workaround did not work for my library and (ng2-charts). I am still getting the error “ng2-charts.js does not export ChartsModule”, does anyone have any other suggestions on how to convert current third party packages to RC0 successfully or maybe any other kind of workaround?

Having same problems, absolutely all external modules/libs not working with RC0.

+1

Same problems with lazy.js 😕