express-routes-mapper
express-routes-mapper copied to clipboard
TypeError: handler is not a constructor
Hello, i'm getting an error just like the same as in the #36
But the weird thing is, the exception only happening on CI/CD which i tried to use both latest alpine
and stretch
images.
Here is the packages in use:
npm-check-updates
[INFO]: You can also use ncu as an alias
Checking /Users/engin/ips/kapca/package.json
[====================] 27/27 100%
convict ^5.1.0 → ^5.2.0
core-js ^2.6.10 → ^3.3.3
debug ~2.6.9 → ~4.1.1
express ~4.16.1 → ~4.17.1
eslint ^4.19.1 → ^6.5.1
eslint-config-airbnb-base ^12.1.0 → ^14.0.0
eslint-plugin-import ^2.11.0 → ^2.18.2
husky ^0.14.3 → ^3.0.9
jest ^24.8.0 → ^24.9.0
nodemon ^1.17.3 → ^1.19.4
shx ^0.2.2 → ^0.3.2
supertest ^3.0.0 → ^4.0.2
and here is the stack trace from the jest
output
TypeError: handler is not a constructor
18 | // const mappedRoutes = mapRoutes(routes, 'api/controllers/');
19 | // eslint-disable-next-line new-cap
> 20 | const mappedRoutes = new mapRoutes(routes, 'api/controllers/');
| ^
21 | app.use('/', mappedRoutes);
22 |
23 |
at node_modules/express-routes-mapper/lib/index.js:108:15
at Array.forEach (<anonymous>)
at new mapRoutes (node_modules/express-routes-mapper/lib/index.js:56:13)
at Object.<anonymous> (config/routes.js:20:22)
at require (test/_setup.js:18:3)
at Object.beforeAction (test/controllers/CaptchaController.test.js:15:15)
Hey,
what version of node, and express routes mapper do you use?
do you use a lock file? do you have a different version of node, express routes mapper locally and on the ci/cd server?
Hello @aichbauer ,
Sorry for the missing description. I don't use lock file; package-lock=false
set in the .npmrc
Project dependencies
"dependencies": {
"convict": "^5.2.0",
"core-js": "^2.6.10",
"express": "~4.17.1",
"express-prettify": "^0.1.1",
"express-prom-bundle": "^5.1.5",
"express-routes-mapper": "^1.1.0",
"express-validator": "^6.2.0",
"got": "^9.6.0",
"morgan": "~1.9.1",
"prom-client": "^11.5.3",
"redis": "^2.8.0",
"svg-captcha": "^1.4.0",
"uuid": "^3.3.3"
},
"devDependencies": {
"eslint": "^6.5.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"husky": "^3.0.9",
"jest": "^24.9.0",
"nodemon": "^1.19.4",
"redis-mock": "^0.46.0",
"shx": "^0.3.2",
"supertest": "^4.0.2"
}
Local node version
➜ kapca (master) ✗ node --version
v12.10.0
Dockerfile
FROM node:12-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
Can you test:
what happens if you add npm install core-js@2 -S
and then run the job again?
what happens if you locally delete the node_modules folder and run npm i
again?
what happens if you remove the npm uninstall core-js@2 -S
dependency again and change the version of express-routes-mapper from ^ 1.1.0
to be explicitly 1.1.0
?
I got the exact message when I composed controller construction function return statement with too many endpoints. So linter should see that stuff was undefined.
Got the same message, but the my controller was wrong. I did not export corectly, so the router did not find it.
I have raised a pull request to resolve this issue. https://github.com/aichbauer/express-routes-mapper/pull/70