{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2192","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2192/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2192/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2192/events","html_url":"https://github.com/Microsoft/TypeScript/issues/2192","id":59734732,"number":2192,"title":"Compiler fails to find external module referenced by two different files","user":{"login":"michael-terry","id":5140538,"avatar_url":"https://avatars.githubusercontent.com/u/5140538?v=3","gravatar_id":"","url":"https://api.github.com/users/michael-terry","html_url":"https://github.com/michael-terry","followers_url":"https://api.github.com/users/michael-terry/followers","following_url":"https://api.github.com/users/michael-terry/following{/other_user}","gists_url":"https://api.github.com/users/michael-terry/gists{/gist_id}","starred_url":"https://api.github.com/users/michael-terry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michael-terry/subscriptions","organizations_url":"https://api.github.com/users/michael-terry/orgs","repos_url":"https://api.github.com/users/michael-terry/repos","events_url":"https://api.github.com/users/michael-terry/events{/privacy}","received_events_url":"https://api.github.com/users/michael-terry/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"vladima","id":8052307,"avatar_url":"https://avatars.githubusercontent.com/u/8052307?v=3","gravatar_id":"","url":"https://api.github.com/users/vladima","html_url":"https://github.com/vladima","followers_url":"https://api.github.com/users/vladima/followers","following_url":"https://api.github.com/users/vladima/following{/other_user}","gists_url":"https://api.github.com/users/vladima/gists{/gist_id}","starred_url":"https://api.github.com/users/vladima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladima/subscriptions","organizations_url":"https://api.github.com/users/vladima/orgs","repos_url":"https://api.github.com/users/vladima/repos","events_url":"https://api.github.com/users/vladima/events{/privacy}","received_events_url":"https://api.github.com/users/vladima/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/8","html_url":"https://github.com/Microsoft/TypeScript/milestones/TypeScript%201.6","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/8/labels","id":900034,"number":8,"title":"TypeScript 1.6","description":"","creator":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"open_issues":96,"closed_issues":25,"state":"open","created_at":"2014-12-11T05:46:12Z","updated_at":"2015-05-22T21:53:18Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-03-04T01:07:19Z","updated_at":"2015-05-22T23:01:58Z","closed_at":null,"body":"(Also posted on StackOverflow: https://stackoverflow.com/questions/28844917/typescript-cant-find-external-module-when-referenced-by-two-different-files)\r\n\r\nI may be missing something obvious, but Typescript's module resolver for commonjs isn't working as expected.\r\n\r\nGiven the following directory structure and files:\r\n\r\n* ./first/shared.ts\r\n* ./first/second/class_a.ts\r\n* ./first/second/class_b.ts\r\n* ./third/class_c.ts\r\n\r\nWhere:\r\n\r\n* class_a references shared.ts\r\n* class_b references class_a.ts and class_c.ts\r\n* class_c references shared.ts\r\n\r\nSpecifically:\r\n\r\nshared.ts:\r\n```typescript\r\nclass Shared{}\r\nexport = Shared;\r\n```\r\n\r\nclass_a.ts:\r\n```typescript\r\nimport Shared = require('../shared');\r\nclass A{}\r\nexport = A;\r\n```\r\nclass_b.ts:\r\n```typescript\r\nimport A = require('./class_a');\r\nimport C = require('../../third/class_c');\r\nclass B {}\r\nexport = B;\r\n```\r\nclass_c.ts:\r\n```typescript\r\nimport Shared = require('../first/shared');\r\nclass C {}\r\nexport = C;\r\n```\r\n\r\nAll compile individually, except class_b.ts, using the following compiler invocation:\r\n\r\n`tsc --module commonjs class_b.ts`\r\n\r\nCompiling class_b.ts fails with the error that it can't find shared.ts:\r\n\r\n`../../third/class_c.ts(1,25): error TS2307: Cannot find external module '../first/shared'.`\r\n\r\nNote that if you reverse the order of imports in class_b.ts, you get a different error:\r\n\r\n`class_a.ts(1,25): error TS2307: Cannot find external module '../shared'.`\r\n\r\nIt seems the compiler is finding shared.ts the first time it is imported, but not the second time.\r\n\r\nThis is with tsc 1.4.1.0."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/104795344","html_url":"https://github.com/Microsoft/TypeScript/issues/2192#issuecomment-104795344","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2192","id":104795344,"user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T23:01:58Z","updated_at":"2015-05-22T23:01:58Z","body":"@canmrt how is this happening with grunt or gulp? if i understand correctly, you have a build file, possibly at the root of your project, and you will always be calling it from the same place.. is that accurate? what is the issue you are seeing?"}}