question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`helmet()` is not a function

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
EvanHahncommented, Jan 17, 2022

This should be fixed in an upcoming version. Please stay tuned!

2reactions
EvanHahncommented, Jan 22, 2022

I just released helmet@5.0.2 which should fix this problem. Please try updating to see if that fixes things for you!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found