3 ms·
When your actual Node .js file runs `require('a')`, it has no context to determine which version it is requiring. To expect Node to look for a package.json file
by dc2 11y ago
When your actual Node .js file runs `require('a')`, it has no context to determine which version it is requiring. To expect Node to look for a package.json file at runtime is absurd. This presents a problem.
- deleted 11y ago[deleted]
- theGimp 11y agoI'm guessing the current behavior for require is to bubble up the directory structure and look for "node_packages". So resolving things at runtime is already happening. I agree using package.json at runtime is not the best solution though. A way to keep things clean and avoid using package.json is to use symlinks instead of downloading a fresh copy, which would make putting everything at the top level a possibility. I'm sure that option was considered, but I'm curious about why it was not taken. I suppose I should look at the discussion notes. Hope I'll remember to do that when I'm home!
- curun1r 11y agoThat version information could be encoded into symlinks if it weren't for the need to support Windows.
- acjohnson55 11y agoWhy is this absurd? Order-dependent installation and massive node_modules trees seem a lot more absurd to me. Why not just have node parse all the package.json's (or, perhaps, npm-shrinkwrap.json) at startup time? Then `require` could easily parse that and know what dependency version from the flat node_modules to deliver.