Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Windows: Loading from the global folders #3462

Closed
wants to merge 1 commit into from

5 participants

@lamb

Fix #3461
Windows do not have HOME environment variable, so that node will not search $HOME/.node_modules and $HOME/.node_libraries.On Windows, a similar environment variable is called USERPROFILE.

@adammw

Might be nicer to wrap each check in a (process.platform === 'win32') check so %HOME% doesn't get used accidentally on Windows, and $USERPROFILE doesn't get used accidentally on Linux (and etc.)

@bnoordhuis

@isaacs, @piscisaureus You guys should review this PR.

@bnoordhuis

Also, see the comments in #3461.

@isaacs
Owner

I'm still not seeing why this is necessary.

  1. It IS the same on both Unix and Windows. It checks the HOME environment variable on both. If you want this feature, set that environment variable. It also checks the NODE_PATH environment variable on both. If you want more control over it, then set that variable instead. (And it checks that one in a proper cross-platform way, separating with ; on Windows, and with : on unix.)
  2. If we could have gotten away with it then, we would have removed support for ~/.node_libraries in 0.4. The problem was that too many people relied on this mistaken API. No one on Windows currently relies on this default, since it was never supported, so this argument does not apply there.
  3. The only argument for making this easier on Windows is that there was not any way to do npm link on windows, making it a bit tricky to set up a module so that it could be loaded in multiple projects with require() without having to reinstall each time. However, in 0.8, npm link works on Windows, so that's not an argument.

I'm happy to hear other reasons why this is necessary that we may have overlooked, but "make it the same" just isn't convincing enough to justify changing the module system in such a way that encourages the use of an API that is a regrettable accident of history. I'm sorry.

@isaacs isaacs closed this
@piscisaureus
Owner

@isaacs This is bugging me:

  • Either we deprecate and actually remove this feature on unix, or
  • I fix this problem.
@piscisaureus
Owner

It IS the same on both Unix and Windows. It checks the HOME environment variable on both. If you want this feature, set that environment variable.

It's not functionally the same. The implementation is the same on windows and unix, which works sometimes on windows and always on unix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 17, 2012
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/module.js
View
5 lib/module.js
@@ -494,6 +494,11 @@ Module._initPaths = function() {
paths.unshift(path.resolve(process.env['HOME'], '.node_libraries'));
paths.unshift(path.resolve(process.env['HOME'], '.node_modules'));
}
+
+ if (process.env['USERPROFILE']) {
+ paths.unshift(path.resolve(process.env['USERPROFILE'], '.node_libraries'));
+ paths.unshift(path.resolve(process.env['USERPROFILE'], '.node_modules'));
+ }
if (process.env['NODE_PATH']) {
var splitter = process.platform === 'win32' ? ';' : ':';
Something went wrong with that request. Please try again.