create-yo
create-yo copied to clipboard
Fix Windows bug
Fixes https://github.com/boneskull/create-yo/issues/4
The problem is that on a regular Windows Node.js installation,
globalDirs.npm.packagespoints to:C:\Users\dev\AppData\Roaming\npm\node_modules.Yet
libnpxis located in the Node.js installation directory at:C:\Program Files\nodejs\node_modules\npm\node_modules\libnpxSo this line files
importFrom(path.join(globalDirs.npm.packages, 'npm'), 'libnpx').Not sure what a clean fix for this looks like.. since
global-dirsis correct in providing the directory for user installed global packages. Tested withglobalDirs.npm.binarieswhich also points to the user dirC:\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?
I'll try this on my windows box later.