{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/3402","labels_url":"https://api.github.com/repos/nodejs/node/issues/3402/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3402/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/3402/events","html_url":"https://github.com/nodejs/node/issues/3402","id":111824392,"number":3402,"title":"Don't resolve symlinks when requiring","user":{"login":"VanCoding","id":595361,"avatar_url":"https://avatars.githubusercontent.com/u/595361?v=3","gravatar_id":"","url":"https://api.github.com/users/VanCoding","html_url":"https://github.com/VanCoding","followers_url":"https://api.github.com/users/VanCoding/followers","following_url":"https://api.github.com/users/VanCoding/following{/other_user}","gists_url":"https://api.github.com/users/VanCoding/gists{/gist_id}","starred_url":"https://api.github.com/users/VanCoding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VanCoding/subscriptions","organizations_url":"https://api.github.com/users/VanCoding/orgs","repos_url":"https://api.github.com/users/VanCoding/repos","events_url":"https://api.github.com/users/VanCoding/events{/privacy}","received_events_url":"https://api.github.com/users/VanCoding/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/module","name":"module","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-10-16T12:45:59Z","updated_at":"2015-10-27T13:58:32Z","closed_at":null,"body":"Currently, Node.js resolves symlinks when requiring and then uses the real location of the package/file as its __filename and __dirname instead of the symlinked one.\r\n\r\nThis is a problem because symlinked modules don't act the same as locally copied modules.\r\n\r\nFor example:\r\n```\r\napp\r\n    index.js //require(\"dep1\")\r\n    node_modules\r\n        dep1\r\n            index.js //require(\"dep2\")\r\n        dep2\r\n            index.js //console.log('fun!'):\r\n```\r\nworks, but\r\n```\r\napp\r\n    index.js //require(\"dep1\")\r\n    node_modules\r\n        dep1 -> ../../dep1\r\n        dep2\r\n            index.js\r\ndep1\r\n    index.js //require(\"dep2\")\r\n```\r\n\r\ndoes not, because dep1 does not act like it's located in the node_modules directory of module and thus cannot find dep2.\r\n\r\nThis is especially a problem when one wants to symlink modules that have peer-dependencies.\r\n\r\nTherefore, I suggest changing the behavior to no longer resolve symlinks.\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/151504276","html_url":"https://github.com/nodejs/node/issues/3402#issuecomment-151504276","issue_url":"https://api.github.com/repos/nodejs/node/issues/3402","id":151504276,"user":{"login":"dlongley","id":168137,"avatar_url":"https://avatars.githubusercontent.com/u/168137?v=3","gravatar_id":"","url":"https://api.github.com/users/dlongley","html_url":"https://github.com/dlongley","followers_url":"https://api.github.com/users/dlongley/followers","following_url":"https://api.github.com/users/dlongley/following{/other_user}","gists_url":"https://api.github.com/users/dlongley/gists{/gist_id}","starred_url":"https://api.github.com/users/dlongley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlongley/subscriptions","organizations_url":"https://api.github.com/users/dlongley/orgs","repos_url":"https://api.github.com/users/dlongley/repos","events_url":"https://api.github.com/users/dlongley/events{/privacy}","received_events_url":"https://api.github.com/users/dlongley/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T13:58:32Z","updated_at":"2015-10-27T13:58:32Z","body":"@asbjornenge,\r\n\r\n> You can't hardlink a directory I think?\r\n\r\nNo, you can't, but maybe you could write a script to create a mock directory and hard link any `js` files. I *think* that would be all it would take for simple modules. It's not a perfect solution but maybe it would help in some cases. Clearly there needs to be a better way to link peer dependencies together during development."}}