create-yo icon indicating copy to clipboard operation
create-yo copied to clipboard

Fix Windows bug

Open zone117x opened this issue 6 years ago • 1 comments

Fixes https://github.com/boneskull/create-yo/issues/4

The problem is that on a regular Windows Node.js installation, globalDirs.npm.packages points to: C:\Users\dev\AppData\Roaming\npm\node_modules.

Yet libnpx is located in the Node.js installation directory at: C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx

So this line files importFrom(path.join(globalDirs.npm.packages, 'npm'), 'libnpx').

Not sure what a clean fix for this looks like.. since global-dirs is correct in providing the directory for user installed global packages. Tested with globalDirs.npm.binaries which also points to the user dir C:\Users\dev\AppData\Roaming\npm.

I'm opening as a draft PR since this is a pretty hacky solution and I'm not thrilled with it, however, it does fix the issue on Windows.

The original bug reporter stated a similar issue was happening on a linux install. I suspect the problem is the same -- depending on how the Node.js installation is packaged, the global-dirs lib makes no sense in this context since this tool is targeting core Node.js components rather than user installed global modules.

Alternative solution (?)

If the core node.js node_modules directory is always located at the location that the npm or npx shell commands evaluate to, then a more elegant and cross platform solution could be using the which package to evaluate the location of npm and use that for locating libnpx.

Thoughts?

zone117x avatar Aug 21 '19 21:08 zone117x

I'll try this on my windows box later.

boneskull avatar May 12 '20 23:05 boneskull