Azure部署Node.js应用遇DEP0064弃用警告致启动失败求助
Hey there, let's tackle this [DEP0064] DeprecationWarning that's stopping your Node.js app from starting on Azure. Here's a step-by-step breakdown to resolve it:
What's Causing This?
The warning flags that your app (or one of its dependencies) is using tls.createSecurePair()—an API that's been deprecated since Node.js v10 and removed in newer versions. Modern Node.js environments (like the one Azure uses) no longer support this method, which is why your app fails to launch.
Step 1: Verify Node.js Version on Azure
First, confirm the Node.js version running on your Azure App Service:
- Go to your App Service in the Azure Portal → Configuration → General settings
- Check the "Node.js version" dropdown. If it's v14 or higher, this deprecated API will definitely break your app.
Step 2: Locate the Problematic Code/Dependency
Check Your Own Code
Search your codebase for any direct calls to tls.createSecurePair(). If you find it, replace it with tls.Socket as recommended. For example, if you had code like:
const tls = require('tls'); const pair = tls.createSecurePair(/* options */);
Replace it with a tls.Socket implementation tailored to your secure connection needs (refer to Node.js core docs for usage specifics matching your use case).
Check Third-Party Dependencies
If your code doesn't use the deprecated API, the issue is in one of your npm packages. To find which one:
- Run this command in your local project directory:
This will list any dependencies that include the deprecated method.npm ls | grep createSecurePair - Once you identify the package, check its GitHub repo or npm page for updates. Most maintainers fix deprecation issues in newer versions—upgrade the package to the latest compatible version using:
npm update [package-name]
Step 3: Adjust Azure Deployment Settings
Ensure you're not uploading local
node_modulesto Azure. Instead, enable automatic dependency installation:- In Azure Portal, go to your App Service → Configuration → Application settings
- Add a new setting with key
SCM_DO_BUILD_DURING_DEPLOYMENTand valuetrue
This forces Azure to runnpm installduring deployment, ensuring dependencies are installed for the Node.js version running on Azure.
Avoid using
NODE_OPTIONS="--no-deprecation"as a quick fix—it only hides the warning, not the underlying issue breaking your app.
Step 4: Dig Into Azure Logs
You mentioned the log path is D:\home\LogFiles\Application>—check the detailed logs here (like application.log) to find the exact file and line number where tls.createSecurePair() is being called. This will speed up pinpointing the problematic code or dependency.
内容的提问来源于stack exchange,提问作者CoderX

