Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Example code in README doesn't work #790

Closed
petertorelli opened this issue Oct 17, 2021 · 4 comments
Closed

fix: Example code in README doesn't work #790

petertorelli opened this issue Oct 17, 2021 · 4 comments
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@petertorelli
Copy link

Description

Following instructions for Express on README.md code fails with: TypeError: Reflect.getMetadata is not a function

Minimal code-snippet showcasing the problem
Simply type the first example in the README of this repo (UserController.ts & app.ts).

Expected behavior

Expecting the example to work.

Actual behavior

Fails to start:

% yarn build (runs tsc on the two .ts files)
% yarn start
:
:
/Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata/ParamMetadata.js:36
            const ParamTypes = Reflect.getMetadata('design:paramtypes', args.object, args.method);
                                       ^

TypeError: Reflect.getMetadata is not a function
    at new ParamMetadata (/Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata/ParamMetadata.js:36:40)
    at /Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata-builder/MetadataBuilder.js:111:31
    at Array.map (<anonymous>)
    at MetadataBuilder.createParams (/Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata-builder/MetadataBuilder.js:111:14)
    at /Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata-builder/MetadataBuilder.js:98:34
    at Array.map (<anonymous>)
    at MetadataBuilder.createActions (/Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata-builder/MetadataBuilder.js:95:34)
    at /Users/ptorelli/study/routing-controller-study/node_modules/routing-controllers/cjs/metadata-builder/MetadataBuilder.js:75:39
    at Array.map (<anonymous>)
: 
: 

My package.json:

% cat package.json 
{
  "name": "routing-controller-study",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "tsc",
    "start": "node ./dist/app.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "class-transformer": "0.3.1",
    "class-validator": "0.12.2",
    "express": "^4.17.1",
    "multer": "^1.4.3",
    "reflect-metadata": "^0.1.13",
    "routing-controllers": "^0.9.0"
  },
  "devDependencies": {
    "@types/body-parser": "^1.19.1",
    "@types/express": "^4.17.13",
    "@types/multer": "^1.4.7",
    "typescript": "^4.4.4"
  }
}

And tsconfig.json:

{
  "exclude": [ "node_modules", "dist" ],
  "include": [ "src/**/*" ],
  "compilerOptions": {
    "target": "es2019",
    "experimentalDecorators": true, 
    "emitDecoratorMetadata": true, 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "outDir": "./dist", 
  }
}
@petertorelli petertorelli added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Oct 17, 2021
@akashdathan
Copy link

I was able to replicate the issue by following the steps provided in the README.md file, attaching the screenshot of the replicated issue. Can I work on this issue? I found the issue and the doc needs to be updated accordingly

Screenshot 2021-12-04 at 11 38 43 AM

@South-Paw
Copy link

#792 fixes this

@attilaorosz
Copy link
Member

Fixed in #712

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

4 participants