diff --git a/doc/api/cli.md b/doc/api/cli.md index 6d055d9d03a6dd..d76c49615c9bca 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -217,6 +217,29 @@ are linked from more than one location in the dependency tree (Node.js would see those as two separate modules and would attempt to load the module multiple times, causing an exception to be thrown). +The `--preserve-symlinks` flag does not apply to the main module, which allows +`node --preserve-symlinks node_module/.bin/` to work. To apply the same +behavior for the main module, also use `--preserve-symlinks-main`. + +### `--preserve-symlinks-main` + + +Instructs the module loader to preserve symbolic links when resolving and +caching the main module (`require.main`). + +This flag exists so that the main module can be opted-in to the same behavior +that `--preserve-symlinks` gives to all other imports; they are separate flags, +however, for backward compatibility with older Node.js versions. + +Note that `--preserve-symlinks-main` does not imply `--preserve-symlinks`; it +is expected that `--preserve-symlinks-main` will be used in addition to +`--preserve-symlinks` when it is not desirable to follow symlinks before +resolving relative paths. + +See `--preserve-symlinks` for more information. + ### `--prof-process`