1

I am running an Express API with Node.js using mssql@3.3.0.

An older version of mssql is being used to align with other compatibility issues that we're having.

However, when trying to use promises to chain requests together I am getting the following error:

DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

How do I disable this warning and run the code in "unsafe" mode using IISNode / Express?

Matthew
  • 1,255
  • 18
  • 43

1 Answers1

1

I ran into this same issue, and here is how I resolved it.

First, as suggested by this question, I added the following code to my web.config file (as a child of system.webServer):

<iisnode nodeProcessCommandLine='"C:\Program Files\nodejs\node.exe" --no-warnings' />

This made it so that all warnings were not sent to stderr. I only wanted to suppress the Buffer() Deprecation warning.

This article explains that even though the no-warnings flag is used, "the Node.js processes object will also emit the warning event". So, I then added the following code to my server.js file:

process.on('warning', (warning) => {
    if (!warning.message.includes("Buffer() is deprecated")) {
        console.error(warning);
    }
});

Now, only the Buffer() Deprecation warning is ignored.

Kade
  • 661
  • 10
  • 17