How to Fix: Error message "node: --openssl-legacy-provider is not allowed in NODE_OPTIONS"
Error message when using Node.js with npm on Ubuntu 20.04 (Focal Fossa) after upgrade.
📋 Table of Contents
The error message 'node: --openssl-legacy-provider is not allowed in NODE_OPTIONS' appears after an update on Ubuntu 20.04 (Focal Fossa) and affects Node.js v18.4.0 users.
This issue can be frustrating for developers who rely on legacy OpenSSL providers, but there are steps to resolve the problem.
⚠️ Common Causes
- The primary reason for this error is that Ubuntu 20.04 (Focal Fossa) has removed support for the --openssl-legacy-provider flag in Node.js by default.
- This change was made as part of a security update and aims to improve the overall security posture of the system.
🔧 Proven Troubleshooting Steps
Enabling the --openssl-legacy-provider flag manually
- Step 1: Open the /etc/node.conf file in a text editor using sudo privileges (e.g., `sudo nano /etc/node.conf`).
- Step 2: Add the following line to the end of the file: `node_options=--openssl-legacy-provider`.
- Step 3: Save and close the file. The changes will take effect during the next Node.js restart.
Using a custom Node.js configuration
- Step 1: Create a new file in the /etc/node.conf.d/ directory (e.g., `sudo nano /etc/node.conf.d/custom_node_options.conf`).
- Step 2: Add the following line to the end of the file: `node_options=--openssl-legacy-provider`.
- Step 3: Save and close the file. This configuration will override the system-wide Node.js settings.
✨ Wrapping Up
By enabling the --openssl-legacy-provider flag manually or using a custom Node.js configuration, you can resolve the 'node: --openssl-legacy-provider is not allowed in NODE_OPTIONS' error on Ubuntu 20.04 (Focal Fossa) with Node.js v18.4.0.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Fix Pc crashes shortly after launching game (rainbow six siege). Compl
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: New PC build- no signal and no clue
Fix New PC build- no signal and no clue. Complete troubleshooting guid