Node.js --preserve-symlinks Flag Support

1.0.0 · maintenance · verified Sun Apr 19

This package, `supports-preserve-symlinks-flag`, is a focused, lightweight utility designed to programmatically determine whether the currently executing Node.js environment supports the `--preserve-symlinks` command-line flag. Currently at version 1.0.0, this package is highly stable and is likely in a maintenance-only mode, with new releases being infrequent unless Node.js introduces significant changes to its symlink resolution mechanisms or CLI flag behavior. Its core differentiation lies in its single-purpose simplicity, providing a direct boolean value (or `null` when executed in a browser environment) indicating support, without relying on any external dependencies. This functionality is crucial for developers needing to adapt application behavior or build processes based on the specific symlink resolution capabilities of the Node.js runtime, especially when deploying across diverse environments that might include older Node.js versions (specifically those prior to v6.2) where this flag was not available. It serves as a reliable check for ensuring compatibility and correct operation of file system-dependent logic.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to import and use the package to determine `--preserve-symlinks` flag support, showing expected values for different environments.

const supportsPreserveSymlinks = require('node-supports-preserve-symlinks-flag');
const assert = require('assert');

// In a browser environment, it will be null.
// In Node.js < v6.2, it will be false.
// In Node.js v6.2+, it will be true.

console.log(`Current environment supports --preserve-symlinks: ${supportsPreserveSymlinks}`);

// Example assertions (uncomment and run in a specific Node.js version for actual results)
// assert.equal(supportsPreserveSymlinks, null); // Run in a browser for this to pass
// assert.equal(supportsPreserveSymlinks, false); // Run in Node.js < v6.2 for this to pass
// assert.equal(supportsPreserveSymlinks, true); // Run in Node.js v6.2+ for this to pass

view raw JSON →