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
Using Express version 4.19.2 in Response.js at line 790 (var charset = mime.charsets.lookup(value.split(';')[0]);) is throwing an exception stating that mime.charset "TypeError: Cannot read properties of undefined (reading 'charsets')"
TypeError: Cannot read properties of undefined (reading 'charsets')
at ServerResponse.header (..\node_modules\express\lib\response.js:790:1)
at ServerResponse.contentType (..\node_modules\express\lib\response.js:625:1)
at setContentTypeMiddleware (..\lib\router\middlewares\setContentType.js:15:1)
at Layer.handle [as handle_request] (..\node_modules\express\lib\router\layer.js:95:1)
at trim_prefix (..\node_modules\express\lib\router\index.js:328:1)
at ..\node_modules\express\lib\router\index.js:286:1
at Function.process_params (..\node_modules\express\lib\router\index.js:346:1)
at next (..\node_modules\express\lib\router\index.js:280:1)
at ..\lib\router\middlewares\setServerUrl.js:26:1
at .webpack\service\src\index.js:154906:9 {stack: 'TypeError: Cannot read properties of undefine…oyment.webpack\service\src\index.js:154906:9', message: 'Cannot read properties of undefined (reading 'charsets')'}
I don't know what serverless offline is, but in the stack I see this is the closes thing that looks like user land code: at ..\lib\router\middlewares\setServerUrl.js:26:1
Also, the npm ls output you showed doesn't show these things afaict. If you think it is something with the packages installed please post more of the output.
Hey @robertlario any chance you remember the solution to this? I'm currently debugging and suspected a versioning issue as well! Just trying to find the right thing to update.
Activity
wesleytodd commentedon Mar 27, 2024
Can you post some example code where it is having this error behavior?
robertlario commentedon Mar 27, 2024
I am trying to run my code in serverless-offline.
I do not call the code directly.
Here is the stack trace:
TypeError: Cannot read properties of undefined (reading 'charsets')
at ServerResponse.header (..\node_modules\express\lib\response.js:790:1)
at ServerResponse.contentType (..\node_modules\express\lib\response.js:625:1)
at setContentTypeMiddleware (..\lib\router\middlewares\setContentType.js:15:1)
at Layer.handle [as handle_request] (..\node_modules\express\lib\router\layer.js:95:1)
at trim_prefix (..\node_modules\express\lib\router\index.js:328:1)
at ..\node_modules\express\lib\router\index.js:286:1
at Function.process_params (..\node_modules\express\lib\router\index.js:346:1)
at next (..\node_modules\express\lib\router\index.js:280:1)
at ..\lib\router\middlewares\setServerUrl.js:26:1
at .webpack\service\src\index.js:154906:9 {stack: 'TypeError: Cannot read properties of undefine…oyment.webpack\service\src\index.js:154906:9', message: 'Cannot read properties of undefined (reading 'charsets')'}
Here are my modules:
@types/cors@2.8.17
├── @types/errorhandler@0.0.32
├── @types/express-serve-static-core@4.17.43
├── @types/express@4.17.21
├── @types/flat@5.0.5
├── @types/http-errors@1.8.2
├── @types/jest@26.0.24
├── @types/lodash@4.14.202
├── @types/mime-types@2.1.4
├── @types/mock-req-res@1.1.6
├── @types/node@12.20.55
├── @types/uuid@3.4.13
├── @typescript-eslint/eslint-plugin@4.33.0
├── @typescript-eslint/parser@4.33.0
├── ajv-errors@1.0.1
├── ajv@6.12.6
├── aws-sdk-mock@5.9.0
├── aws-sdk@2.1573.0
├── aws-xray-sdk@3.5.4
├── cors@2.8.5
├── errorhandler@1.5.1
├── eslint-config-airbnb-base@14.2.1
├── eslint-config-prettier@8.10.0
├── eslint-plugin-import@2.29.1
├── eslint-plugin-prettier@4.2.1
├── eslint@7.32.0
├── express@4.19.2
├── flat@5.0.2
├── force@0.0.3
├── http-errors@1.8.1
├── jest-each@26.6.2
├── jest-mock-extended@1.0.18
├── jest@26.6.3
├── lodash@4.17.21
├── mime-types@2.1.35
├── mime@4.0.1
├── mock-req-res@1.2.1
├── prettier@2.8.8
├── serverless-http@2.7.0
├── sinon@10.0.1
├── standard-version@9.5.0
├── supertest@6.3.4
├── ts-jest@26.5.6
├── typescript@4.9.5
├── uuid@8.3.2
wesleytodd commentedon Mar 27, 2024
I don't know what serverless offline is, but in the stack I see this is the closes thing that looks like user land code:
at ..\lib\router\middlewares\setServerUrl.js:26:1robertlario commentedon Mar 27, 2024
at line 34 in response.js
send.mime appears to be undefined.
Any thoughts?
wesleytodd commentedon Mar 27, 2024
https://github.com/pillarjs/send/blob/master/index.js#L71
I looked at that initially and am not sure how it could be. That is why I would need more to go off of to debug.
wesleytodd commentedon Mar 27, 2024
Also, the
npm lsoutput you showed doesn't show these things afaict. If you think it is something with the packages installed please post more of the output.robertlario commentedon Mar 27, 2024
It was a versioning issue! :-( What a nightmare!
Please consider the issue closed. Thank you for your help!
wesleytodd commentedon Mar 27, 2024
Haha, no problem. Glad you got it sorted out!
wilcoxmd commentedon Mar 8, 2025
Hey @robertlario any chance you remember the solution to this? I'm currently debugging and suspected a versioning issue as well! Just trying to find the right thing to update.