angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Server side rendering "TypeError: Reflect$1.getOwnMetadata is not a function"

Open lucaswxp opened this issue 9 years ago • 10 comments

Bug Report or Feature Request (mark with an x)

- [ x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.3.1 node: 7.10.1 os: darwin x64

Repro steps.

Following the docs in https://github.com/angular/angular-cli/blob/1.3.x/docs/documentation/stories/universal-rendering.md

I get

/Users/lucaswxp/xxx/site/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 (/Users/lucaswxp/doare/site/node_modules/@angular/core/bundles/core.umd.js:501:51)
    at __decorate (/Users/lucaswxp/doare/site/node_modules/angular2-text-mask/dist/angular2TextMask.js:5:110)
    at Object.<anonymous> (/Users/lucaswxp/doare/site/node_modules/angular2-text-mask/dist/angular2TextMask.js:88:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

Not sure if it's a angular bug, but I followed all the steps mentioned in the docs. Any help?

lucaswxp avatar Aug 22 '17 23:08 lucaswxp

Guys, I see this is an actual angular cli bug? Any idea how can I fix it temporarily?

lucaswxp avatar Aug 29 '17 19:08 lucaswxp

Hello, any updates on this? I'm about to launch a big project and we need this working.

Appreciate the support.

ruyfortini avatar Aug 30 '17 21:08 ruyfortini

@hansl appreaciate if you can give us a date estimate for this fix.

ruyfortini avatar Aug 30 '17 21:08 ruyfortini

@hansl @ruyfortini Is there any temporary way around this bug? Anything at all I can do just to load my site somewhere?

DISRUPTIVE-INC avatar Sep 03 '17 01:09 DISRUPTIVE-INC

@hansl @ruyfortini Quick update, I only get this error if I try to include this plugin: https://github.com/mujtaba01/ngx-owl-carousel. I assume that's not related to the bug but is instead a universal thing?

DISRUPTIVE-INC avatar Sep 04 '17 20:09 DISRUPTIVE-INC

same problem with universal have you solved yet? @lucaswxp @EmptyPockets

BlankHrt avatar Sep 15 '17 12:09 BlankHrt

I get this error message building an universal project without angular-cli, so I guess it is rather a platform-server issue.

hlszk avatar Sep 18 '17 06:09 hlszk

I think it is because you are using a dependency that uses methods not supported in node: http://node.green/#ESNEXT-pre-strawman-Metadata-reflection-API-Reflect-getOwnMetadata

In your case is 'angular2-text-mask'

diegofin avatar Sep 21 '17 18:09 diegofin

At server level you need to include a reflect polyfill such as reflect-metadata.

Please take a look at this story https://github.com/angular/angular-cli/wiki/stories-universal-rendering and this starter https://github.com/angular/universal-starter/blob/master/server.ts#L2

alan-agius4 avatar Oct 08 '18 07:10 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.