             [entry entry-file]
             (or (reduce
                   (fn [_ entry]
-                    (when-let [file (or (test-file package-dir entry)
-                                        ;; some libs have main:"some/dir/foo" without the .js
-                                        (test-file-exts npm package-dir entry))]
+                    ;; test file exts first, so we don't pick a directory over a file
+                    ;; lib/jsdom
+                    ;; lib/jsdom.js
+                    (when-let [file (or (test-file-exts npm package-dir entry)
+                                        (test-file package-dir entry))]
 
                       (reduced [entry file])))
                   nil

    (util/is-relative? require)
    (find-relative npm require-from require)

    ;; FIXME: do node libs ever have nested things?
    ;; path/foo would not be overridden by path
    :else
    (let [browser-override
          (and require-from
               (let [{:keys [browser-overrides] :as require-from-pkg}
                     (find-package-for-file npm require-from)]
                 (get browser-overrides require)))

          override
          (if (some? browser-override)
            browser-override
            (get node-libs-browser require))]
      (cond
        (false? override)
        false

        (nil? override)
        (find-package-require npm require)

        ;; "foo":"bar"
        :else
        (find-package-require npm override)
        ))))


          ;; FIXME: is "./lib/some-file.js":"some-package" allowed?
          ;; currently assumes its always a file in the package itself
          (and (string? override)
               (util/is-relative? override))
          (let [override-file
                (-> (io/file package-dir override)
                    (.getCanonicalFile))]
