Skip to content

experimental-specifier-resolution=node doesn't resolve realpath #42195

Closed
@vjpr

Description

@vjpr

Version

v17.6.0

Platform

Darwin VMBP2021.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64

Subsystem

esm resolver

What steps will reproduce the bug?

https://github.com/vjpr/issue-node-experimental-specifier-resolution

pnpm install
./index.sh

How often does it reproduce? Is there a required condition?

Pnpm relies on realpaths. Package managers relying on hoisting will not encounter this issue as they will eventually find the package hoisted.

This is why it was probably hard to detect.

What is the expected behavior?

Realpath should be called when --experimental-specifier-resolution=node is set.

What do you see instead?

It's not being called, and modules are resolved using logical paths.

Additional information

https://github.com/nodejs/node/blame/e5c1fd7a2a1801fd75bdde23b260488e85453eb2/lib/internal/modules/esm/resolve.js#L367-L410

Notice how realpathSync is not called if the --experimental-specifier-resolution=node option is set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    loadersIssues and PRs related to ES module loaders

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions