`helmet()` is not a function
See original GitHub issueI’m currently using Nest.js 8.1.5.
I have tested helmet 4.6.0
and 5.0.1
with the same results.
This is my server file:
import { NestFactory } from '@nestjs/core'
import helmet from 'helmet';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
app.use(helmet());
await app.listen(AppModule.applicationPort);
}
bootstrap()
When I try to run it, it prints this to console.
TypeError: (0 , helmet_1.default) is not a function
at bootstrap (/Users/jeffreymesa/Desktop/dev.nosync/yp-micro/yp-lottery-api-gateway/src/main.ts:14:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How to use helmet.js from typescript? - Stack Overflow
import helmet this way: import * as helmet from 'helmet';. to avoid the following warning: TypeError: helmet_1.default is not a function.
Read more >TypeError: helmet.xframe is not a function · Issue #122 - GitHub
Try using helmet.frameguard instead. 3
Read more >helmet - npm
Helmet helps you secure your Express apps by setting various HTTP headers. It's not a silver bullet, but it can help!
Read more >How to use the helmet.noCache function in helmet - Snyk
To help you get started, we've selected a few helmet.noCache examples, based on popular ways it is used in public projects.
Read more >What is Helmet.js & Why it is a Security Best Practice For ...
The reason for this is because Express is designed for creating web applications — not securing your Node.js server from vulnerabilities. The ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed in an upcoming version. Please stay tuned!
I just released
helmet@5.0.2
which should fix this problem. Please try updating to see if that fixes things for you!