-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module.globalPaths under Windows #6434
Comments
@nodejs/ctc @orangemocha ... thoughts on this one? |
/cc @nodejs/platform-windows |
It's definitely not a feature request since atm it does not allow to require globally installed modules because of this bug. node -p "require('npm');" // Cannot find module
npm i -g anything
node -p "require('anything');" // Still cannot find module |
AFAIK requiring a module installed with From https://docs.npmjs.com/files/folders:
Agreed that that code is Unix-specific. From https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders:
None of those paths make sense on Windows, and the use of |
SGTM |
Don't overlook the line in the documentation immediately following the listing of search locations:
I think many Windows users would reasonably interpret "the user's home directory" to be %USERPROFILE% on Windows. So dropping support for loading modules from 1 and 2 above could be considered a breaking change. (And that may be fine, since all these ways of finding modules are essentially deprecated anyway. But it should be deliberate.) I agree that the 3rd location based on $PREFIX doesn't make sense on Windows. |
Ran into this whilst trying to setup working files which are held locally on several machines and synced via the cloud which makes global installs problematic. It seems sensible that a configuration file be held at a fixed location in relation to the install but that initial configuration file should be capable of pointing to a second configuration file where all other file paths may be referenced so as to allow the configuration of different machines to point to the same data. This would allow for a separation of what is synced (and is the same) and what is not (which may be different). |
Should this remain open? If so, is it a documentation issue or more than that? |
#9283 fixed the global paths folder on Windows. |
Looks like code at https://github.com/nodejs/node/blob/master/lib/module.js#L590:
is Unix specific and since
nodejs
is installed asc:\program files\nodejs\node.exe
the base path resolved to'C:\\Program Files\\lib\\node'
, and it's pointless.Guess this should be fixed to
path.resolve(process.env.AppData, 'npm', 'node_modules')
for windows, or something similar since right there node_modules are placed by default in win7+.The text was updated successfully, but these errors were encountered: