Information Security with HelmetJS - Install and Require Helmet

const package.json = require("helmet");

You should assign it to a helmet variable.


As an aside:

package.json is a file on disk that contains the dependencies and scripts (among other things). You are trying to use it as if it was an object with a property on it. For one, the object doesn’t exist in your code, secondly, you can’t do an assignment to a property when declaring an object.

const obj.prop = 'test'
Uncaught SyntaxError: Missing initializer in const declaration
const obj = {}
obj.prop = 'test'
console.log(obj.prop) // test
2 Likes