Home > front end >  NodeModules\serve-static\index.js Error :48
NodeModules\serve-static\index.js Error :48

Time:04-22

can anyone help me on this error please:-

Image of the error line :https://i.stack.imgur.com/Xqgh6.png

Image of the server :https://i.stack.imgur.com/e1e1t.png

CodePudding user response:

In line 48 of index.js, if options is falsy, then you are trying to create an object with value null, which is why it is throwing the error. I think what you want is this:

var opts = options ? Object.create(options) : null;

CodePudding user response:

@MForMarlon: This is not gonna work if options are Not_An_Object_Or_Null as the error suggests, which mean if you assign options = a number/string, anything that's not an Object or null (aka primitive), the check in your answer won't be able to prevent the error.

@Supratim Purkait: you can add a console.log statement before line 48 to see the options value you are passing to the function - as the error say: it is not an object nor null.
And the way you create an object from options looks weird. Normally you just do: opts = options || {};

So to resolve this issue, make sure options is an object or null first.

  • Related