Skip to content

Module resolution should not succeed but does #43342

Closed

Description

@amcasey

a.ts

export {}

b.ts

import "BAD/../../a";

node_modules/
Present but empty

Expected: import fails to resolve
Actual: import resolves because we look in node_modules/BAD/../../a, which simplifies to a.

The path normalization in question happens here.

Activity

  1. amcasey commented on Mar 23, 2021

    @amcasey
    MemberAuthor

    Maybe we need to normalize the path before checking if it's relative?

  2. amcasey commented on Mar 23, 2021

    @amcasey
    MemberAuthor

    I suppose there's a tiny chance this is desirable, even if it appears to be happening by accident. Sheetal Nandi (@sheetalkamat) ?

  3. amcasey commented on Mar 23, 2021

    @amcasey
    MemberAuthor

    On further reflection, the is-relative-path check probably needs to check path components after the first one.

  4. sheetalkamat commented on Mar 23, 2021

    @sheetalkamat
    Member

    I dont think this is issue with module resolution.. Node works in similar way. If you make those file at runtime as js files and run them it works

    c:\temp\test>type a.js
    module.exports = { a: 10};
    c:\temp\test>type b.js
    const r = require("BAD/../../a");
    console.log(r);
    c:\temp\test>dir node_modules
     Volume in drive C is OSDisk
     Volume Serial Number is F41A-DBC9
    
     Directory of c:\temp\test\node_modules
    
    03/23/2021  01:40 PM    <DIR>          .
    03/23/2021  01:40 PM    <DIR>          ..
                   0 File(s)              0 bytes
                   2 Dir(s)  689,911,324,672 bytes free
    
    c:\temp\test>node b.js
    { a: 10 }
    
  5. amcasey commented on Mar 23, 2021

    @amcasey
    MemberAuthor

    Well, now I'm sad.

  6. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions