Riron / ionic-img-viewer

Ionic 2+ component providing a Twitter inspired experience to visualize pictures.
MIT License
283 stars 118 forks source link

ngc error: Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule' #9

Closed longfay closed 8 years ago

longfay commented 8 years ago

Hi! Thanks for your contribution on the plugin. I am using Ionic2(not the beta one) and when I wanna import your ionic-ing-viewer to my NgModule, there exists an error:

ngc error: Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule'

Does anyone have any idea how it comes? Thanks in advance!

Riron commented 8 years ago

Hi, thanks for opening an issue.

Are you importing the module like this import { IonicImageViewerModule } from 'ionic-img-viewer'; ?

If yes, you can try import { IonicImageViewerModule } from 'ionic-img-viewer/module';. This has something to do with rollup configuration in Ionic.

But it should work without it if you have the latest version. Also make sure you use the latest version of the plugin (1.1.1).

longfay commented 8 years ago

Thanks very much for your quick reply Riron!

Yes I am using import { IonicImageViewerModule } from 'ionic-img-viewer'; in my app.module.ts file. I tried import { IonicImageViewerModule } from 'ionic-img-viewer/module'; and also I use the version 1.1.1 of ionic-ing-viewer.

My ionic version is 2.1.0.

Unfortunately, it continues to give out the error message: ngc error: Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule'. which is the same as the error above. :(

I don't know how can it comes up lol. But thanks for your reply! If you have any other possible solutions please let me know. :)

dmastag commented 8 years ago

Same here, I also tried to do the following

Import using import { IonicImageViewerModule } from 'ionic-img-viewer/src/module';

Adding into rollup config

plugins: [
        builtins(),
        commonjs({
            include: [
                'node_modules/rxjs/**',
                'node_modules/ionic-img-viewer/**',
            ],
            namedExports: {
                'node_modules/ionic-img-viewer/ionic-img-viewer.js': ['IonicImageViewerModule']
            }
        }),
        nodeResolve({
            module: true,
            jsnext: true,
            main: true,
            browser: true,
            extensions: ['.js']
        }),
        globals(),
        json()
    ]

But still getting the same problem

image

Riron commented 8 years ago

You shouldn't have to modify your rollup config. Do you have the latest @ionic/app-scripts installed ? ("@ionic/app-scripts": "^0.0.36" in your package.json)

longfay commented 8 years ago

I have updated to @ionic/app-scripts": "^0.0.36 in my package.json. Same error lol.

antonioloiaconodev commented 8 years ago

i have this problem when run build but with serve comand worked! Help me

antonioloiaconodev commented 8 years ago

I have this error when build ios platform [10:50:42] Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule'
[10:50:42] ngc failed
[10:50:42] ionic-app-script task: "build"
[10:50:42] Error: Error

dmastag commented 8 years ago

Am also on 0.0.36 and its still happening Any information I could provide to help you find the problem?

antonioloiaconodev commented 8 years ago

hello guys, I want to help you! I have solved so: https://github.com/driftyco/ionic-cli/issues/1504. Riron may close this issue and focus on the slide ahhah xD I hope I've helped hello, see you soon

dmastag commented 8 years ago

@kadox07 how exactly did you get this working ? Tried using the --dev and still isn't working for me.

antonioloiaconodev commented 8 years ago

into package.json try overwrite your "scripts" with this: "scripts": { "build": "ionic-app-scripts build --dev", "watch": "ionic-app-scripts watch", "serve:before": "watch", "emulate:before": "build", "deploy:before": "build", "build:before": "build", "run:before": "build" }

hugovl74 commented 8 years ago

@kadox07, thank you, works flawlessly!

dmastag commented 8 years ago

@kadox07 I did that, and its not working. Its also just a work around isn't it? And its downgrading performance by removing AOT

Riron commented 8 years ago

Indeed support for AOT compiling was missing. Could you please try the 1.1.2 release ? This should be fixed by now.

dmastag commented 8 years ago

Hi @Riron , Tried it as per readme and its not working.

Also tried to change the import into: import { IonicImageViewerModule } from 'ionic-img-viewer/dist/src/module';

And try to update the rollup.

Any idea what I am doing wrong?

image

Riron commented 8 years ago

Keep the import { IonicImageViewerModule } from 'ionic-img-viewer'; import, it's the correct one.

Are you doing a ionic serve or a ionic build ? Or maybie you have the problem in both cases ?

dmastag commented 8 years ago

Noted on the setup. Its on ionic serve

gfviegas commented 8 years ago

I'm also having the same issue, using the new version @Riron . It reports me in the console:

main.js:25715 Uncaught Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule'

Usin' ionic serve and importing like:

import { IonicImageViewerModule } from 'ionic-img-viewer';

dmastag commented 8 years ago

The weird thing is that this is working as expected on a new ionic2 project. But I can't get it to work on an existing project.

dmastag commented 8 years ago

I tried to copy the src folder into my Ionic2 App and Imported the module.ts directly. Its is working this way. Sadly I don't really understand how to create npm modules so I can't help or create a pull request.

Riron commented 8 years ago

As you're saying, I tried creating a new Ionic2 project and it worked. It probably has something to do with your build phase or dependencies versions, but I cannot reproduce the bug.

niconaso commented 8 years ago

@Riron I think the problem is associated with angular ngc.

lingyilun commented 8 years ago

My mistake is the same, ngc error: Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule' Someone has a solution?

niconaso commented 8 years ago

I'm getting the same error on version 1.1.3 when I try to build for Android (ionic build android)

[08:32:49] Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule' [08:32:49] ngc failed [08:32:49] ionic-app-script task: "build" [08:32:49] Error: Error

My system info:

Cordova CLI: 6.3.1 Ionic Framework Version: 2.0.0-rc.2 Ionic CLI Version: 2.1.7 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.19 Node Version: v6.7.0 Xcode version: Not installed

Riron commented 8 years ago

Do you have @angular/compiler installed locally ? Under what version ? It seems to be due to versions mismatch, but i'm cannot be sure yet...

And if you run ngc instead of the classic ionic serve, could you please post the stack trace here ? Thanks.

niconaso commented 8 years ago

@Riron I have a local @angular/compiler version is 2.1.1 It executes well with ionic serve but it fails when I run ionic build android. I don't know how to compile with ngc, could you help me?

Riron commented 8 years ago

You can run node_modules/.bin/ngc, with double quotes if you're on windows "node_modules/.bin/ngc".

niconaso commented 8 years ago

I executed node_modules/.bin/ngc and showed me this error:

Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule' at /home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:14078:37 at Array.forEach (native) at CompileMetadataResolver.getNgModuleMetadata (/home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:14063:46) at /home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:12865:47 at Array.forEach (native) at analyzeModules (/home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:12864:17) at OfflineCompiler.analyzeModules (/home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:12889:18) at CodeGenerator.codegen (/home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler-cli/src/codegen.js:121:47) at codegen (/home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/compiler-cli/src/main.js:7:81) at Object.main (/home/nicolas/desarrollo/workspace/runrun-3-mobile/node_modules/@angular/tsc-wrapped/src/main.js:30:16) Compilation failed

niconaso commented 8 years ago

@Riron I forgot to mention on my previous comment

lingyilun commented 8 years ago

@Riron Thank you, I can already use

Riron commented 8 years ago

@lingyilun what do you mean ? It's working now ?

@niconaso thanks for sthe stack trace. It seems that ngc cannot locate the module metadata, but the metadata ARE bundled into the library, as needed for AOT to work. And it works indeed for most people with RC2...

It might be linked to some node_modules version problem but I am not sure. Maybie the Ionic folks have an idea on what's going on ? @danbucholtz

niconaso commented 8 years ago

@Riron Your're welcome! I've tested with ionic-app-scripts version 0.0.45 and I doesn't work with ionic serve nor ionic build ...

This is my system information:

Cordova CLI: 6.3.1 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.7 Ionic App Lib Version: 2.1.4 Ionic App Scripts Version: 0.0.45 ios-deploy version: Not installed ios-sim version: Not installed OS: Linux 3.19 Node Version: v6.7.0 Xcode version: Not installed

niconaso commented 8 years ago

@Riron I think the author of this module https://github.com/fiznool/angular2-elastic could help you this fix this issue

lingyilun commented 8 years ago

@Riron I'm not sure though before my question was

ngc error: Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule'

but when I updated later it's pass and

into package.json try overwrite your "scripts" with this: "scripts": { "build": "ionic-app-scripts build --dev", "watch": "ionic-app-scripts watch", "serve:before": "watch", "emulate:before": "build", "deploy:before": "build", "build:before": "build", "run:before": "build" } works flawlessly!

Riron commented 8 years ago

Things might be better in 1.1.5, with https://github.com/Riron/ionic-img-viewer/commit/f0d2b71c1f5f8e9c76cdfb75b1d3cf8c4389a210.

Please tell me if you see any improvement... Sorry about all that, the path to AOT support is not very clear

niconaso commented 8 years ago

@Riron thanks to you! I'll test it when you release the next version. Thanks again!

niconaso commented 8 years ago

@Riron it works perfect!! Thank you very much!

Riron commented 8 years ago

Finally ! Good to hear 👍 If nobody complains about it still not working for a few days, i'll close the issue.

SealTecH commented 8 years ago

Hi @Riron, I have same problem.. I tried to insert this into package.json "build": "ionic-app-scripts build --dev", "watch": "ionic-app-scripts watch", "serve:before": "watch", "emulate:before": "build", "deploy:before": "build", "build:before": "build", "run:before": "build"

but still have an error Uncaught Error: Unexpected value 'IonicImageViewerModule' imported by the module 'AppModule'

Information Cordova CLI: 6.3.1 Ionic Framework Version: 2.0.0-rc.1 Ionic CLI Version: 2.1.7 Ionic App Lib Version: 2.1.4 Ionic App Scripts Version: 0.0.36 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 7 Node Version: v6.7.0 Xcode version: Not installed

Can you help me?

Riron commented 8 years ago

The fix is only available for the latest versions: ionic-angular@2.0.0-rc.3 and ionic-img-viewer@1.1.5. Please upgrade

niconaso commented 8 years ago

@Riron bad news! I tested on Ubuntu and it fails again :(

It throws this:

[19:19:07] Error: Error at /home/nicolas/desarrollo/workspace/runrun-3-mobile/.tmp/pages/timeline/timeline.ngfactory.ts:1531:38 [19:19:07] Module ''*'' has no exported member 'Wrapper_ImageViewerDirective'. [19:19:07] Error at /home/nicolas/desarrollo/workspace/runrun-3-mobile/.tmp/pages/comments/comments.ngfactory.ts:1253:38 [19:19:07] Module ''*'' has no exported member 'Wrapper_ImageViewerDirective'. [19:19:07] Error at /home/nicolas/desarrollo/workspace/runrun-3-mobile/.tmp/pages/profile/profile.ngfactory.ts:984:38 [19:19:07] Module ''*'' has no exported member 'Wrapper_ImageViewerDirective'. [19:19:07] ngc failed [19:19:07] ionic-app-script task: "build" [19:19:07] Error: Error

Your system information:

Cordova CLI: 6.3.1 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.7 Ionic App Lib Version: 2.1.4 Ionic App Scripts Version: 0.0.46 ios-deploy version: Not installed ios-sim version: Not installed OS: Linux 3.19 Node Version: v6.7.0 Xcode version: Not installed

vazad28 commented 8 years ago

@niconaso, I too am seeing the same error. If I use --dev flag in the build its ok but without it I too am seeing this error.

SealTecH commented 8 years ago

yea, after update to rc3 I have same error

Riron commented 8 years ago

As mentioned here, could you try to remove the node_modules directory from your project, and then run npm install inside of your project ?

vazad28 commented 8 years ago

@Riron , I tried your suggestion on a new ionic test app as well but still the same error [17:09:26] Error: Error at /Users/vik/Developer/IonicFirebase/test/testApp/.tmp/pages/home/home.ngfactory.ts:120:39 [17:09:26] Module ''*'' has no exported member 'Wrapper_ImageViewerDirective'. [17:09:26] ngc failed [17:09:26] ionic-app-script task: "build" [17:09:26] Error: Error

lingyilun commented 8 years ago

@Riron 1.1.5 works perfect!! Thank you very much! I remove the node_modules and then run npm install, All the problems are solved

Information: ordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.12 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.46 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 7 Node Version: v7.0.0 Xcode version: Not installed

vazad28 commented 8 years ago

Hi, I am just curious (perplexed why it is still not working for me) if this is working without --dev flag or with --dev flag for everyone.

lingyilun commented 8 years ago

@vazad28 my package.json working without --dev flag Is there an error in your app.module.ts? And you can provide yours system information?

vazad28 commented 8 years ago

@lingyilun, thank you for following up and offering to help. Here is my ionic info Your system information:

Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.13 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.46 ios-deploy version: 1.9.0 ios-sim version: 5.0.11 OS: macOS Sierra Node Version: v7.2.0 Xcode version: Xcode 8.0 Build version 8A218a

If I use --dev flag or use -lc flag it works but not otherwise

lingyilun commented 8 years ago

@vazad28 your version of the ionic-img-viewer is 1.1.5? If version 1.1.3 is required use --dev flag