Skip to content

Node.js-like module resolution doesn't follow parent paths #5102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
heycalmdown opened this issue Oct 4, 2015 · 8 comments
Closed

Node.js-like module resolution doesn't follow parent paths #5102

heycalmdown opened this issue Oct 4, 2015 · 8 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@heycalmdown
Copy link

When I have following environment

  • parent
    • node_modules
      • my-proper-external-module
        • index.d.ts
        • index.js
    • my-application
      • index.ts (import m_p_e_m from 'my-proper-external-module')

It couldn't resolve where the my-proper-external-module is.

It should work according the proposal (#2338) and the source code(https://github.com/Microsoft/TypeScript/blob/b95e1ff6d8656693c80ac54a15893c3ad4859762/src/compiler/program.ts#L125).

I think it's come from by the directory which the loadModuleFromNodeModules have is empty string. It is an empty so it can not follow recursively.

Below is my tsconfig.json

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "moduleResolution": "node"
  },
  "files": [
    "./a.ts"
  ]
}
@heycalmdown
Copy link
Author

Got it.

When if I compile like this

tsc --project .

doesn't work. But when if

tsc --project $(pwd)

works.

@mhegazy mhegazy self-assigned this Oct 5, 2015
@mhegazy mhegazy added the Bug A bug in TypeScript label Oct 5, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Oct 6, 2015

looks like this is fixed in master. can you give typescript@next a try?

@mhegazy mhegazy closed this as completed Oct 6, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Oct 6, 2015
@mhegazy mhegazy added this to the TypeScript 1.7 milestone Oct 6, 2015
@heycalmdown
Copy link
Author

@mhegazy mhegazy reopened this Oct 10, 2015
@mhegazy mhegazy removed the Fixed A PR has been merged for this issue label Oct 10, 2015
@alexeagle
Copy link
Contributor

Same issue with some angular2 users who put their tsconfig.json under a src folder.
Workaround is to run tsc from the parent directory and use the -p flag.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 27, 2015

should be handled by #5275

@vladima vladima added the Fixed A PR has been merged for this issue label Oct 27, 2015
@vladima
Copy link
Contributor

vladima commented Oct 27, 2015

fixed in e811fec

@mhegazy
Copy link
Contributor

mhegazy commented Oct 27, 2015

@alexeagle and @heycalmdown can you give tomorrow's typescript@next a try?

@heycalmdown
Copy link
Author

Sure, I was waiting your go sign.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants