Issues with Install and Require Helmet

Tell us what’s happening:
Hello everyone, I have the following error doing the install and require helmet challenge:
“throw new TypeError('Router.use() requires a middleware function but got a ’ + gettype(fn)).”

  1. I only cloned the github repo:
    GitHub - freeCodeCamp/boilerplate-infosec: A boilerplate for the freeCodeCamp curriculum.
  2. Installed and required helmet
  3. And it’s not working, I think the error is in this line
    app.use(’/_api’, api);

Because you have to give a middleware function and the variable api contains an object.

I need help please

My code so far

const express = require(‘express’);
const app = express();

const helmet = require (‘helmet’);

module.exports = app;
const api = require(’./server.js’);
app.use(’/_api’, api);
app.get("/", function (request, response) {
response.sendFile(__dirname + ‘/views/index.html’);
let port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(Your app is listening on port ${port});


“name”: “fcc-infosec-challenges”,
“version”: “0.0.1”,
“description”: “fcc backend boilerplate”,
“main”: “server.js”,
“scripts”: {
“start”: “node myApp.js”
“dependencies”: {
“express”: “^4.17.1”,
“helmet”: “3.21.3”
“keywords”: [
“license”: “MIT”

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Challenge: Install and Require Helmet

Link to the challenge:

I already solve the issue. It was that I was starting with node server.js and it need to be started with node myApp.js instead :sweat_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.