Ng-lazyload-image: Error after installing it and when i am using SSR angular universal

Created on 13 Sep 2017  ·  7Comments  ·  Source: tjoskar/ng-lazyload-image

node_modules/@angular/core/bundles/core.umd.js:501
var /** @type {?} */ meta = Reflect$1.getOwnMetadata('propMetadata', target.constructor) || {};
^

TypeError: Reflect$1.getOwnMetadata is not a function
at PropDecorator

Most helpful comment

You need in your server.ts file include this line at the top of imports import 'core-js/es7/reflect'; or import 'reflect-metadata';

All 7 comments

@dkmostafa, are you sure your error is related to this library? From your stack trace it looks like you have an error in node_modules/bundles/core.umd.js (which is not included in this library)? Do you still get this error if you remove the import of ng-lazyload-image?

After i removed the ng-lazyload-image library , and removing it from the app.module.ts the project worked perfectley .

This is the full trace of the error .

TypeError: Reflect$1.getOwnMetadata is not a function
at PropDecorator (/project/node_modules/@angular/core/bundles/core.umd.js:501:51)
at __decorate (/project/node_modules/ng-lazyload-image/src/lazyload-image.directive.js:5:110)
at project/node_modules/ng-lazyload-image/src/lazyload-image.directive.js:62:5
at Object. (/project/node_modules/ng-lazyload-image/src/lazyload-image.directive.js:97:2)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)

Yeah, after installing this plugin I have the same problem. @angular/cli build app via ng build --prod, but when I try to execute code in server side above TypeError occurs.

It happens with some dependencies:
https://github.com/angular/angular-cli/issues/7476

when using Universal

Somewhere there is a need for the metadata reflection API (getOwnMetadata) that Node does not support

I have done some googling and it seems to be a problem in angular-cli/universal rather than in this library. Please let me know if I'm wrong!

You need in your server.ts file include this line at the top of imports import 'core-js/es7/reflect'; or import 'reflect-metadata';

Was this page helpful?
0 / 5 - 0 ratings