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.
Same problem
With ng2-translate
Having same problems, absolutely all external modules/libs not working with RC0.
You can use this workaround:
edit file node_modules/@ionic/app-scripts/config/rollup.config.js
useStrict:
false to the module.exports
object'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']
}
}),
@dr1v3 What's the workaround for relative templates within external libraries? With your workaround I'm now getting:
Error reading template file, "my-component-tpl.html": Error: ENOENT: no such file or directory
ending with node_modules/@angular/core/src/animation/my-component-tpl.html'
and
Error: Module <...>/node_modules/rxjs/Subject.js does not export Subject (imported by <...>/node_modules/@angular/core/src/facade/async.js)
at Module.trace (<...>/node_modules/rollup/dist/rollup.js:7677:29)
Thanks, @dr1v3. That workaround worked for me.
I'm having a similar problem with ng2-cordova-oauth. The error message I get is as following:
Error: Module **/node_modules/ng2-cordova-oauth/core.js does not export CordovaOauth
.
Will try workaround shortly to see if it works
Update:
Thanks @dr1v3. Workaround works. The following is the config for ng2-cordova-oauth in commonjs:
`
include: [
'node_modules/ng2-cordova-oauth/**',
'node_modules/rxjs/**'
],
namedExports: {
'node_modules/ng2-cordova-oauth/core.js' : ['CordovaOauth', 'Facebook', 'Google']
}
`
How can we disable the rollup until this issue is not fixed?
+1 Same problem
having a similar problem with moment library.... anyone have a fix on how to use moment?
I have import * as moment from 'moment';
And on compile i get cannot call a namespace ('moment') ?
Same problems with lazy.js :/
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?
@dr1v3 Question: i have followed your instructions and the app now compiles but do i have manually include all the external libraries in index.html ? that seems to be the only way they start working?
see my config below - lots of libraries, but for example moment does not end up included and i need to manually go and add it to the index.html?
include: [
'node_modules/rxjs/**',
'node_modules/angular2-moment/**',
'node_modules/breeze-bridge-angular2/**',
'node_modules/@ionic/storage/**',
'node_modules/breeze-client/**',
'node_modules/moment/moment.min.js',
'node_modules/google-lib-phonenumber/dist/**',
'node_modules/jquery/dist/jquery.js',
'node_modules/lodash/**'
],
namedExports: {
'node_modules/angular2-moment/index.js' : ['MomentModule'],
'node_modules/breeze-client/breeze.base.debug.js' : ['EntityState', 'core', 'NamingConvention','FetchStrategy', 'EntityManager', 'EntityQuery', 'FilterQueryOp', 'Predicate'],
'node_modules/moment/moment.js' : ['moment'],
'node_modules/lodash/lodash.js' : ['_'],
'node_modules/jquery/dist/jquery.js' : ['jQuery'],
'node_modules/google-lib-phonenumber/dist/libphonenumber.js': ['default']
}
@ganySA, your config seems to be right. I'm using moment.js too, but i didn't add anything into the index.html file. I haven't got to get to work angular2-moment, so i've created my custom moment pipe like this:
src/pipes/moment.ts:
import { Pipe, PipeTransform} from '@angular/core';
import moment from 'moment';
@Pipe({ name: 'moment' })
export class MomentPipe implements PipeTransform{
transform(value) {
return moment(value).fromNow();
}
}
make shure to add this pipe to the app.module.ts
:
import {MomentPipe} from "../pipes/moment";
...
@NgModule({
declarations: [
...,
MomentPipe
],
i'm uing this pipe like this:
{{someVar | moment}}
This issue was moved to driftyco/ionic-app-scripts#68
Hello all! Because this issue is a build related issue I have moved this issue to the app-scripts repo. Thanks!
+1
There is an even more simple workaround:
Instead of
import { MomentModule } from 'angular2-moment';
do
import { MomentModule } from 'angular2-moment/module';
@DenisVuyka - did you get around the following?
Error reading template file, "my-component-tpl.html": Error: ENOENT: no such file or directory, open '/home/lathonez/code/myApp/node_modules/angular2-signaturepad/node_modules/@angular/core/src/animation/my-component-tpl.html'
@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.
use recent version from npm, urish fixed the rollup issues..
Most helpful comment
@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.