• Register
0 votes

Problem :

I am beginner to Angular 2. Currently I am trying to learn more about the server rendering with the help of Angular2, I am trying to use the gulp instead of webpack. But my problem is when my server starts then I start facing below error :

        throw 'reflect-metadata shim is required when using class decorators';
reflect-metadata shim is required when using class decorators

I have also tried some solutions mentioned online but they are not working on my code. How can I fix my code ?

8 4 2
2,300 points

1 Answer

0 votes

Solution :

I was reading few questions and I came across your question here. I had also faced the similar issue recently. I can give you some solutions for your issue just check if they can fix your error as below.

You can try to add the import 'reflect-metadata'; to your server.ts file as it will help you in server rendering. After adding that small line of code my errors got fixed.

You can also try add the div tag. Similar to the directive the component HTML tag should be enclosed in the div tag as shown below


When you will enclose your .HTML tag in div as shown above then your errors will be fixed.

5 2 1
4,980 points

Related questions

0 votes
1 answer 31 views
Problem: I am naive to Angular, Webpack, Bootstrap and typescript. I have tried to write a service but it is throwing the below error while my app is bootstrapping. I am currently using ng2 2.4.2 and the angular-cli 1.0.0-beta.24. My TypeError as below: &ldquo;Uncaught typeerror: ... .navigate(['/project', query]); } public extractData(res: Response) { let body = res.json(); return body || {}; } }
asked Sep 3 Raphael Pacheco 4.9k points
0 votes
1 answer 47 views
Problem: Recently I have joined the angular2 project. But now I am stuck with below listed errors. The errors occurred if I tried to send my JSON objects to my backend. It may be due a parsing of my JSON objects. I am very new to angualar so unable to find ... (core.umd.js:3971) at ZoneDelegate.invokeTask (zone.js:274) at Zone.runTask (zone.js:151) at XMLHttpRequest.ZoneTask.invoke (zone.js:345)
asked Aug 5 Raphael Pacheco 4.9k points
0 votes
1 answer 143 views
Problem : I am beginner to Angular. I have recently started to use the ng serve but now I continuously get below error. &ldquo;A bad http response code (404) was received when fetching the script.&rdquo; I have already tried to do lot of research on it but still I don&rsquo;t have any solution on it. Can somebody help me in resolving the errors ?
asked Mar 5 mphil 2.3k points