sindresorhus / open

Open stuff like URLs, files, executables. Cross-platform.
MIT License
3.18k stars 219 forks source link

Cannot access 'mountPoint' before initialization #230

Closed umonaca closed 3 years ago

umonaca commented 3 years ago

open\index.js:25:3 throws this error on Node v14.15.1. Platform: Windows Powershell 7.1.2 on Windows 10.

rjwut-chg commented 3 years ago

I am also experiencing this under Powershell on Windows 10. The last version of open that worked was v7.4.2. Looking at the code for index.js on v8.0.1, it looks like mountPoint is initialized on line 49, way below line 25 where it gets referenced.

umonaca commented 3 years ago

To author:
You have deleted the line

let mountPoint

since commit 8c00bd89d4604f9ec70568dce466a2162b30bcb1. But you forgot that the mountPoint is still referenced in that function.

rjwut-chg commented 3 years ago

Assuming it was intentional, it looks like the let mountPoint was deleted in order to narrow its scope to the function being returned by the IIFE that sets the value of getWslDrivesMountPoint, implying that mountPoint is no longer supposed to be memoized. If that is the case, then lines 25-28 should be deleted.

If it still should be memoized, then I'm guessing that the let mountPoint declaration deleted in commit 8c00bd8 should be restored, and the const keyword currently found on line 49 should be removed.

sindresorhus commented 3 years ago

// @Richienb

Richienb commented 3 years ago

Looks like a badly handled merge conflict.