Registry / devops / supports-preserve-symlinks-flag

supports-preserve-symlinks-flag

JSON →
library1.0.0jsnpmunverified

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.

npm install supports-preserve-symlinks-flag
INSTALL
IMPORT
SIG · SUPPORTS-PRESERVE-
S
supports-preserve-symlinks-flag
devopsjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

supportsPreserveSymlinks
const supportsPreserveSymlinks = require('node-supports-preserve-symlinks-flag');
This package exports a primitive boolean (or null) directly via `module.exports`.
supportsPreserveSymlinks
import supportsPreserveSymlinks from 'node-supports-preserve-symlinks-flag';
import supportsPreserveSymlinks from 'node-supports-preserve-symlinks-flag';
While some ESM environments (like Node.js with `--experimental-modules` or bundlers) might allow this for CJS interop, it technically relies on Node.js's CJS-to-ESM wrapper for `module.exports` to become the default export. It is not a native ESM default export.
supportsPreserveSymlinks
import * as supportsPreserveSymlinksModule from 'node-supports-preserve-symlinks-flag'; const supportsPreserveSymlinks = supportsPreserveSymlinksModule.default || supportsPreserveSymlinksModule;
import { supportsPreserveSymlinks } from 'node-supports-preserve-symlinks-flag';
This package does not use named exports. Attempting a named import (`{ supportsPreserveSymlinks }`) will result in `undefined` for the symbol. If using `import * as pkg`, the actual value might be under `pkg.default` or `pkg` directly depending on the runtime's CJS interop.

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
Debug
Known issues
gotchaThe package returns `null` when executed in a browser environment, as the concept of Node.js-specific CLI flags is irrelevant there. Be sure to handle this case if your code might run client-side.
fix
Check for `null` explicitly: `if (supportsPreserveSymlinks === null) { /* browser-specific logic */ } else if (supportsPreserveSymlinks) { /* Node.js supported */ } else { /* Node.js not supported */ }`
affects: >=1.0.0
gotchaThis package is a CJS module. When used in a pure ESM project (e.g., with `"type": "module"` in `package.json`), direct `require()` calls are not available, and ESM `import` statements may behave differently depending on Node.js version and bundler configuration.
fix
For ESM, consider dynamic import: `const { default: supportsPreserveSymlinks } = await import('node-supports-preserve-symlinks-flag');` or use a bundler that handles CJS interop.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` directly in a pure ES module (`.mjs` file or `"type": "module"` package).
fix
Use dynamic import: `const { default: supportsPreserveSymlinks } = await import('node-supports-preserve-symlinks-flag');` or convert your file to CommonJS (`.cjs` or remove `"type": "module"` from `package.json`).
TypeError: supportsPreserveSymlinks is not a function
Mistaking the exported boolean value for a function and attempting to call it.
fix
The package exports a direct boolean (or null) value, not a function. Use it as a variable: `if (supportsPreserveSymlinks) { ... }`.
ESM import 'node-supports-preserve-symlinks-flag' results in undefined or empty object
Incorrectly importing a CJS package that exports a primitive directly via `module.exports` using ESM named imports (`import { symbol } from 'package'`).
fix
Use the default import syntax for CJS interop, typically `import supportsPreserveSymlinks from 'node-supports-preserve-symlinks-flag';` or dynamic import to access `default`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
supports-preserve-symlinks-flag — npm install supports-preserve-symlinks-flag · libregistry