Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to declare in App Module #20

Closed
Saulgor opened this issue Oct 3, 2016 · 28 comments
Closed

Unable to declare in App Module #20

Saulgor opened this issue Oct 3, 2016 · 28 comments
Milestone

Comments

@Saulgor
Copy link

Saulgor commented Oct 3, 2016

Uncaught Error: Unexpected value 'PdfViewerComponent' declared by the module 'AppModule'
at http://localhost:3000/vendor.bundle.js:12183:31
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:3000/vendor.bundle.js:12170:49)
at RuntimeCompiler._compileComponents (http://localhost:3000/vendor.bundle.js:18476:47)
at RuntimeCompiler.compileModuleAndComponents (http://localhost:3000/vendor.bundle.js:18414:37)
at RuntimeCompiler.compileModuleAsync (http://localhost:3000/vendor.bundle.js:18405:21)
at PlatformRef
.bootstrapModuleWithZone (http://localhost:3000/vendor.bundle.js:26818:25)
at PlatformRef
.bootstrapModule (http://localhost:3000/vendor.bundle.js:26800:21)
at HTMLDocument.main (http://localhost:3000/main.bundle.js:89232:10)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:15379:38)
at Zone.runTask (http://localhost:3000/polyfills.bundle.js:15279:48)
at HTMLDocument.ZoneTask.invoke (http://localhost:3000/polyfills.bundle.js:15447:34)

@driff
Copy link

driff commented Oct 17, 2016

i got the same issue, have you figured out what could be the problem?
i'm using angular-cli, do i need to specify some js?

@VadimDez
Copy link
Owner

Did you include ng2-pdf-viewer and pdfjs-dist ?
https://github.com/VadimDez/ng2-pdf-viewer/blob/master/SYSTEMJS.md

@driff
Copy link

driff commented Oct 18, 2016

sorry for the question but is there anyway to add that in angular-cli?, i'm not using systemjs, angular cli doesn't creates one, i tried adding "pdf-viewer.component.min.js" to angular-cli.json but it throws the same error, also added "../node_modules/pdfjs-dist/build/pdf.js" to the scripts path in angular-cli.json but i have the same error.

@fvdavid
Copy link

fvdavid commented Oct 18, 2016

@VadimDez same errors using commonJs

@John-Diego
Copy link

I am having the same issue

@grimabe
Copy link

grimabe commented Oct 19, 2016

Same for me

@nessgor
Copy link

nessgor commented Oct 24, 2016

@Saulgor can you provide more information for @VadimDez to examine the issue? For example package.json and other related docs.

@Saulgor
Copy link
Author

Saulgor commented Oct 25, 2016

@driff
For urgent situation, I just use <object></object> as alternative plan like this:

<object [data]="src" type="application/pdf" width="100%" height="600px"><p>Alternative text - include a link <a href="http://www.pdf995.com/samples/pdf.pdf">to the PDF!</a></p></object>

@nessgor I'm using webpack, this is my package.json
{
"name": "angular2-webpack-starter",
"version": "5.0.5",
"description": "An Angular 2 Webpack Starter kit featuring Angular 2 (Router, Http, Forms, Services, Tests, E2E, Coverage), Karma, Protractor, Jasmine, Istanbul, TypeScript, and Webpack by AngularClass",
"keywords": [
"angular2",
"webpack",
"typescript"
],
"author": "Patrick Stapleton patrick@angularclass.com",
"homepage": "https://github.com/angularclass/angular2-webpack-starter",
"license": "MIT",
"scripts": {
"build:dev": "webpack --config config/webpack.dev.js --progress --profile",
"build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .",
"build:prod": "webpack --config config/webpack.prod.js --progress --profile --bail",
"build": "npm run build:dev",
"ci": "npm run lint && npm test && npm run e2e",
"clean:dist": "npm run rimraf -- dist",
"clean:install": "npm set progress=false && npm install",
"clean:start": "npm start",
"clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist",
"docker": "docker",
"docs": "npm run typedoc -- --options typedoc.json --exclude '/*.spec.ts' ./src/",
"e2e:live": "npm run e2e -- --elementExplorer",
"e2e": "npm run protractor",
"github-deploy:dev": "webpack --config config/webpack.github-deploy.js --progress --profile --github-dev",
"github-deploy:prod": "webpack --config config/webpack.github-deploy.js --progress --profile --github-prod",
"github-deploy": "npm run github-deploy:dev",
"lint": "npm run tslint "src/
/*.ts"",
"postversion": "git push && git push --tags",
"prebuild:dev": "npm run clean:dist",
"prebuild:prod": "npm run clean:dist",
"preclean:install": "npm run clean",
"preclean:start": "npm run clean",
"pree2e": "npm run webdriver:update -- --standalone",
"preversion": "npm test",
"protractor": "protractor",
"rimraf": "rimraf",
"server:dev:hmr": "npm run server:dev -- --inline --hot",
"server:dev": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/",
"server:prod": "http-server dist --cors",
"server": "npm run server:dev",
"start:hmr": "npm run server:dev:hmr",
"start": "npm run server:dev",
"test": "karma start",
"tslint": "tslint",
"typedoc": "typedoc",
"version": "npm run build",
"watch:dev:hmr": "npm run watch:dev -- --hot",
"watch:dev": "npm run build:dev -- --watch",
"watch:prod": "npm run build:prod -- --watch",
"watch:test": "npm run test -- --auto-watch --no-single-run",
"watch": "npm run watch:dev",
"webdriver-manager": "webdriver-manager",
"webdriver:start": "npm run webdriver-manager start",
"webdriver:update": "npm run webdriver-manager update",
"webpack-dev-server": "webpack-dev-server",
"webpack": "webpack"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "^2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"@angular/router": "3.0.0",
"@angular2-material/core": "^2.0.0-alpha.8-2",
"@angular2-material/tabs": "^2.0.0-alpha.8-2",
"@angularclass/conventions-loader": "^1.0.2",
"@angularclass/hmr": "~1.2.0",
"@angularclass/hmr-loader": "~3.0.2",
"@angularclass/request-idle-callback": "^1.0.7",
"@angularclass/webpack-toolkit": "^1.3.3",
"angular2-data-table": "^0.6.1",
"angular2-modal": "^2.0.0-beta.13",
"assets-webpack-plugin": "^3.4.0",
"bootstrap-sass": "^3.3.7",
"core-js": "^2.4.1",
"fullcalendar": "^3.0.0",
"fullcalendar-scheduler": "^1.4.0",
"http-server": "^0.9.0",
"ie-shim": "^0.1.0",
"jquery": "^3.1.0",
"moment": "2.13.0",
"ng2-file-upload": "^1.1.0",
"ng2-pdf-viewer": "0.0.12",
"ng2-slim-loading-bar": "^2.0.3",
"primeng": "^1.0.0-beta.14",
"rxjs": "5.0.0-beta.12",
"zone.js": "~0.6.17"
},
"devDependencies": {
"@types/core-js": "^0.9.34",
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.34",
"@types/node": "^6.0.38",
"@types/protractor": "^1.5.20",
"@types/selenium-webdriver": "2.44.29",
"@types/source-map": "^0.1.27",
"@types/uglify-js": "^2.0.27",
"@types/webpack": "^1.12.34",
"angular2-template-loader": "^0.5.0",
"awesome-typescript-loader": "^2.2.1",
"codelyzer": "~0.0.28",
"copy-webpack-plugin": "^3.0.1",
"css-loader": "^0.25.0",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"file-loader": "^0.9.0",
"gh-pages": "^0.11.0",
"html-webpack-plugin": "^2.21.0",
"imports-loader": "^0.6.5",
"istanbul-instrumenter-loader": "^0.2.0",
"json-loader": "^0.5.4",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0 ",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.0.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-remap-coverage": "^0.1.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "1.8.0",
"node-sass": "^3.10.0",
"parse5": "^1.3.2",
"phantomjs": "^2.1.7",
"protractor": "^3.2.2",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"sass-loader": "^4.0.2",
"source-map-loader": "^0.1.5",
"string-replace-loader": "1.0.5",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.4",
"ts-helpers": "1.1.1",
"ts-node": "^1.3.0",
"tslint": "3.15.1",
"tslint-loader": "^2.1.3",
"typedoc": "^0.4.5",
"typescript": "2.0.3",
"url-loader": "^0.5.7",
"webpack": "2.1.0-beta.22",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^2.1.0-beta.2",
"webpack-md5-hash": "^0.0.5",
"webpack-merge": "^0.14.1"
},
"repository": {
"type": "git",
"url": "https://github.com/angularclass/angular2-webpack-starter.git"
},
"bugs": {
"url": "https://github.com/angularclass/angular2-webpack-starter/issues"
},
"engines": {
"node": ">= 4.2.1",
"npm": ">= 3"
}
}

@nessgor
Copy link

nessgor commented Oct 25, 2016

I am building an Ionic2 app based on ng2-pdf-viewer and it works like charm. I am using the following dependencies in package.json. I got the same error message if I use yours, please check whether this helps.

    "@angular/common": "^2.0.0",
    "@angular/compiler": "^2.0.0",
    "@angular/compiler-cli": "0.6.2",
    "@angular/core": "^2.0.0",
    "@angular/forms": "^2.0.0",
    "@angular/http": "^2.0.0",
    "@angular/platform-browser": "^2.0.0",
    "@angular/platform-browser-dynamic": "^2.0.0",
    "@angular/platform-server": "^2.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.21"
  },
  "devDependencies": {
    "typescript": "^2.0.3"
  }

I have wiped out the dependencies involving ionic and the above is NOT tested in angular2 so please handle with care ;)

@nessgor
Copy link

nessgor commented Oct 26, 2016

Just updated the dependencies and got the error again ......
ionic serve is doing good, can test on chrome, pdf viewer runs normally
ionic build failed, cannot compile

Error: Unexpected value 'PdfViewerComponent' declared by the module 'AppModule'

dependencies:

  "dependencies": {
    "@angular/common": "2.1.0",
    "@angular/compiler": "2.1.0",
    "@angular/compiler-cli": "0.6.2",
    "@angular/core": "2.1.0",
    "@angular/forms": "2.1.0",
    "@angular/http": "2.1.0",
    "@angular/platform-browser": "2.1.0",
    "@angular/platform-browser-dynamic": "2.1.0",
    "@angular/platform-server": "2.1.0",
    "@ionic/storage": "1.0.3",
    "ionic-angular": "2.0.0-rc.1",
    "ionic-native": "2.2.3",
    "ionicons": "^3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.25",
    "angular2-jwt": "0.1.23",
    "ng2-pdf-viewer": "0.0.13"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.36",
    "typescript": "^2.0.3"
  },

@nessgor
Copy link

nessgor commented Oct 26, 2016

https://forum.ionicframework.com/t/how-to-declare-a-custom-directive-in-rc0/65403/7

Dunno whether the above thread gives any clues.
The thread metions the 3rd party library do not support the AoT compiler so the module shows error when compile.

http://blog.mgechev.com/2016/08/14/ahead-of-time-compilation-angular-offline-precompilation/

More information about AoT and JiT compiler

@Quocnamit
Copy link

I have the same issue . I'm building my application on Ionic 2

@ghost
Copy link

ghost commented Oct 26, 2016

Same issue here. I tried to integrated the ng2-pdf-viewer into one of Ionic 2 RC1 starter apps (tabs).

Now, both ionic serve and npm run build (production build with ng-compiler) fail with the same error message: ionic serve fails at run time (because the ng-compiler is invoked then); npm run build fails at build time.

I noticed that ng2-pdf-viewer has @angular versions ^2.1.1 in its package.json. Ionic 2 RC1 just uses @angular versions 2.0.0.I manually removed the node_modules folder under node_modules/ng2-pdf-viewer. Now, ionic serve runs fine! However, production build still fails...

@ntourne
Copy link

ntourne commented Oct 27, 2016

Same issue here,

@Quocnamit
Copy link

I think that this error happens because this library is not support building with NGC.
angular/angular#11262 (comment)

I'm trying to fix this issue

@Quocnamit
Copy link

Quocnamit commented Oct 31, 2016

Hi @VadimDez ,

We are using your libary which runs well with JiT mode. We want to use it in AoT mode which is required *.metadata.json along with *.d.ts. could you support us ?

Please refer this article !

Thanks,
Nam

@VadimDez
Copy link
Owner

@Quocnamit Thanks! Going to try that

VadimDez added a commit that referenced this issue Nov 1, 2016
VadimDez added a commit that referenced this issue Nov 1, 2016
VadimDez added a commit that referenced this issue Nov 1, 2016
@VadimDez VadimDez added this to the 0.0.14 milestone Nov 1, 2016
@VadimDez VadimDez closed this as completed Nov 1, 2016
@VadimDez
Copy link
Owner

VadimDez commented Nov 1, 2016

Thanks a lot for your feedback!

@Quocnamit
Copy link

Quocnamit commented Nov 2, 2016

@VadimDez It works well now. and pass NGC. Thank you for your effort

@nessgor
Copy link

nessgor commented Nov 2, 2016

@VadimDez Thank you very much !!! Everything is doing good now ~

@jose2007kj
Copy link

jose2007kj commented Nov 4, 2016

.when i am running the app pdf is not visible in chrome browser and android device............but its visible in firefox...................i am getting a warnining like........warning:setting up fakeworker.............where i might be going wrong

@VadimDez
Copy link
Owner

VadimDez commented Nov 4, 2016

@jose2007kj, that warning is ok. Check pdf path.

@jose2007kj
Copy link

jose2007kj commented Nov 26, 2016

sir....i gave path as https://vadimdez.github.io/ng2-pdf-viewer/pdf-test.pdf and am getting a blank page as output in chrome and also in android(after build).when try to open in firefox its working without any issues

@jose2007kj
Copy link

@Quocnamit , @nessgor .......sir were u able to view pdf in android device and chrome browser

@nessgor
Copy link

nessgor commented Dec 2, 2016

@jose2007kj Yes I can, I think its about the cross origin problemif your pdf src is on remote server.

For desktop chrome browser you can try install
https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi
and add the desired domain to allow cross origin access

@jose2007kj
Copy link

@nessgor thanks sir for quick replay .....ok i will try that......i previously tried this.pdf ='./assets/pdf-test.pdf'; it also did't work both on chrome browser and android device.....Also sir do i need to add anything extra for getting it working in android deivice..........

@VadimDez
Copy link
Owner

VadimDez commented Dec 2, 2016

@jose2007kj may be a compatibility issue as well as #32

@jose2007kj
Copy link

@VadimDez ok sir.....thanks for replay.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants