Reflect.metadata is not a function
andrzejkupczyk opened this issue · 6 comments
Environment
node v16.20.0 (npm v8.19.4)
Reproduction
Run npm audit fix
within the Nuxt 2 project and try to build the app.
Describe the bug
The reflect-metadata
dependency is missing.
Additional context
I was able to solve this issue by adding the reflect-metadata
dependency to my project and importing it. It seems that this is related to the v1.17.2 patch, specifically the addition of support to emit decorator metadata (#119). My suspicion is that reflect-metadata
should not be included in the dev dependencies.
Logs
FATAL Reflect.metadata is not a function
Hi dear @andrzejkupczyk. Is is possible for your to make a small reproduction repo?
Hey @pi0, thank you for the prompt reply. Alright, I'll work on preparing such a repository when I have some free time. Thanks!
package.json
{
"name": "jiti-145",
"author": "Sirenko Vlad",
"devDependencies": {
"jiti": "^1.19.1",
"typescript": "^5.1.6"
}
}
index.ts
function define(target: unknown, _: unknown) {
};
@define
export class Test {
constructor() {
}
}
❯ npx jiti index.ts
<cut>/jiti-145/node_modules/jiti/lib/index.js:2
throw err; /* ↓ Check stack trace ↓ */
^
TypeError: Reflect.metadata is not a function
at <cut>/jiti-145/index.ts:5:24
at evalModule (<cut>/jiti-145/node_modules/jiti/dist/jiti.js:1:255106)
at jiti (<cut>/jiti-145/node_modules/jiti/dist/jiti.js:1:253034)
at Object.<anonymous> (<cut>/jiti-145/node_modules/jiti/bin/jiti.js:16:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Node.js v18.17.0
Thanks a bunch, @sirenkovladd! ❤️
@pi0 maybe it would be better to fork babel-plugin-transform-typescript-metadata
and solve this problem?
should be fixed in v2