Skip to content

lib: fix --preserve-symlinks-main

Rodrigo Muino Tomonari requested to merge github/fork/per4uk/my-branch into main

lib: fix --preserve-symlinks-main

When the --preserve-symlinks-main flag is used when running a node, the main file path is resolved to the target path instead of the symlink path. This cause issues with relative imports. This problem occurs when the called symlink does not contain a file extension(i.e. node package, node package/file).

In the loader.js file, there is a function called tryExtensions which in turn calls tryFile. The tryFile function originally only had a check for the --preserve-symlinks flag, so I have added a check for --preserve-symlinks-main as well.

Fixes: https://github.com/nodejs/node/issues/41000

Merge request reports

Loading