You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uncaught reflect-metadata shim is required when using class decorators #353
You can workaround this for the time being by adding the following to the top of your polyfills.ts
import 'zone.js'; import 'reflect-metadata';
Reacted by ctodea, DooSik Kang, Xiao Gui, Andrew Barsukov, Valentino, Mike Wight, Mohammad Kermani, Jacques Cornat, Dhrumil Bhankhar, Fernando Nogueira and 15 more
Did you find any solution?
I got this error when I import to main.ts:
EXCEPTION: TypeError: s.replace is not a function zone.ts?7d96:3
Adding to polyfills.ts doesn't help.
When i try to bundle reflect-metadata with webpack i'm getting lot of warnings along with the following errors. Should i ignore these errors for my production build ?
Not sure if we had the same issue but I was getting this exception even though the shim was being packaged and loaded before the vendor bundle. This worked for me:
Reacted by Luidgi Gromat, Alexei, Bojan Tosic, Anton Stoychev, Cody Lohse, PatrickJS, Julen, ostap1010, Please go to https://github.com/clair-hu, Matt Massey and 11 more
I'm having this issue when I try to use decorators in my e2e tests. Should it still be enough to import zone.js and reflect-metadata in the polyfills-file when running tests?
I literally tried everything, and I am feeling that I am shooting in the dark here. Whatever I do I get the same error
[15:22:41] I/direct - Using ChromeDriver directly...
[15:22:41] I/launcher - Running 1 instances of WebDriver
[15:22:48] E/launcher - Error: reflect-metadata shim is required when using class decorators
[15:22:48] E/launcher - Process exited with error code 100
Error: Cannot find module 'reflect-metadata'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/Users/_____/HybridApps/testing/betaProject/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4: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)
it works correctly. So now I changed the chunksSortMode in HtmlWebpackPlugin like that:
chunksSortMode: function (a, b) {
var order = ["polyfills", "libs", "js", "vendor", "main"];
return order.indexOf(a.names[0]) - order.indexOf(b.names[0]);
}
Reacted by soromamadou, antonovicha, Dmitriy, TaylorPzreal, donduni, Mohan Chaudhary, hghammoud, José G. Ramírez, Bendy Zhang, Munish Kumar and 2 more
Reacted by José G. Ramírez, Bendy Zhang and Leal Li
Reacted by Akkusativobjekt, Sergey Rozhkov, Rene Ramirez, José G. Ramírez and Leal Li
@Phmager I can't thank you enough! I spend working days solving this issue and was about to give up. I do not understand why this nasty bug (race condition style) doesn't generate more noise/attention.
If you were not already in Munich, I would send you a beer over as reward for solving the issue 😉
Activity
simonturner commentedon Feb 24, 2016
You can workaround this for the time being by adding the following to the top of your polyfills.ts
import 'zone.js';import 'reflect-metadata';omerbenamram commentedon Feb 24, 2016
It ended up working when i used it in main.ts and not polyfills.
I must say i'm not completely certain on why this is happening.
Spittal commentedon Mar 1, 2016
I've tried this fix and now I am getting
Any ideas?
skrywus commentedon Mar 2, 2016
Did you find any solution?
I got this error when I import to main.ts:
EXCEPTION: TypeError: s.replace is not a function zone.ts?7d96:3
Adding to polyfills.ts doesn't help.
PatrickJS commentedon Mar 12, 2016
@skrywus can I see your repo
PatrickJS commentedon Mar 13, 2016
can you pull latest and open another issue if you still have a problem thanks
brunolm commentedon Jul 9, 2016
With
"zone.js": "^0.6.12"TypeScript won't allow me toimport 'zone.js';, but I could import the other one.What can I do?
Currently working around it with
require('zone.js');PatrickJS commentedon Jul 10, 2016
see polyfills
https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/polyfills.browser.ts
it's
import 'zone.js/dist/zone';happyvig commentedon Jul 27, 2016
Still, its not working for me. I used
import 'zone.js/dist/zone'. I have the exact code similar to angular2-webpack-starter.Any updates on this issue ?
PatrickJS commentedon Jul 27, 2016
are you using npm version 3.x.x?
npm --versionhappyvig commentedon Jul 28, 2016
3.10.5 it is.
umasgn commentedon Aug 8, 2016
When i try to bundle reflect-metadata with webpack i'm getting lot of warnings along with the following errors. Should i ignore these errors for my production build ?

brunolm commentedon Aug 8, 2016
@umasgn add this on top of your entry file:
For some reason webpack needs this. Not sure if it will fix your issue in particular tho.
My entry file looks like this:
Also, I'm not using
typings, I'm usingnpmumasgn commentedon Aug 9, 2016
Thank you very much for your reply. I modified file as you mentioned, this time getting different errors 'duplicate identifier .....'.
Downgrade reflect-metadata to "reflect-metadata": "^0.1.3" solved the problem.
radusuciu commentedon Aug 30, 2016
Not sure if we had the same issue but I was getting this exception even though the shim was being packaged and loaded before the vendor bundle. This worked for me:
valdemarrolfsen commentedon Sep 8, 2016
I'm having this issue when I try to use decorators in my e2e tests. Should it still be enough to import zone.js and reflect-metadata in the polyfills-file when running tests?
I literally tried everything, and I am feeling that I am shooting in the dark here. Whatever I do I get the same error
gromatluidgi commentedon Nov 7, 2016
Thanks @radusuciu , thats fix the problem for me
syedfarrukhqamar commentedon Jan 1, 2017
Dear all i am getting the same error
every thing was working fine and then the error started. Is there any quick fix for it. I am new in this and its getting very hard to fix it. Thanks
keywords if/then/else require v5 option
module.js:472
throw err;
^
Error: Cannot find module 'reflect-metadata'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/Users/_____/HybridApps/testing/betaProject/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4: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)
0xphilipp commentedon Jul 4, 2017
For me it seems like the main.js is loaded before the polyfills.js.
When I look at the index.html generated from aot, it generated this:
when I turn it around to this:
it works correctly. So now I changed the chunksSortMode in HtmlWebpackPlugin like that:
Akkusativobjekt commentedon Jul 5, 2017
@Phmager I can't thank you enough! I spend working days solving this issue and was about to give up. I do not understand why this nasty bug (race condition style) doesn't generate more noise/attention.
If you were not already in Munich, I would send you a beer over as reward for solving the issue 😉
kotpal commentedon Jul 13, 2017
Running into the same issue on TOH Part 6 sample and following the steps at https://angular.io/guide/aot-compiler
@Phmager : Where are the aot index.html and HtmlWebpackPlugin? I can't find them.
This is so frustrating that a standard example and guidelines on angular.io aren't working right off the bat.
soromamadou commentedon Jul 19, 2017
Thanks very much @Phmager . I work fine. Good job
TaylorPzreal commentedon Jul 24, 2017
@when i use in
Chromium,i get this error,i found the order of scripts:when i use in
Chrome, it's success and order is this:I thought this error maybe becauseof browser and order.
so i changed the webpack config of HtmlWebpackPlugin and it works correctly.
darincardin commentedon Aug 1, 2017
Same issue when i run a npm build with the production flag:
webpack -p --progress
singhmohancs commentedon Aug 17, 2017
@Phmager Thank you for a solution. Resolved issue.
CodeSaysItBetter commentedon Oct 30, 2017
Thanks brunolm - Had this problem that solved the problem