Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Move npm files into %appdata% on windows 7 / vista #2207

Closed
klovadis opened this Issue · 13 comments

5 participants

klovadis isaacs Bert Belder Igor Zinkovsky Cameron Howey
klovadis

After installing node using the .msi installer, node is being installed into the "Program Files (x86)" folder, where node does not have any permissions. Thus when using npm, you cannot install global modules, because node cannot write into the "Program Files (x86)\nodejs\node_modules" folder.

Instead, node.exe should store and look for npm modules somewhere in the user %appdata% folder.

isaacs
Owner

That is by design. If you start a cmd shell as administrator, then you'll have escalated permissions, and be able to write to the global folder. Or you can do npm config set prefix C:\blahblahblah to point it somewhere else.

That being said, I'm not sure of the proper customs on Windows. @igorzi @piscisaureus care to weigh in?

Bert Belder

@isaacs I actually agree with @klovadis

Igor Zinkovsky igorzi closed this
Igor Zinkovsky igorzi reopened this
Igor Zinkovsky
Owner

Oops, accidentally closed the issue.

Igor Zinkovsky
Owner

yeah, %programfiles% is probably not the right place for node_modules, also because it gets uninstalled when users upgrade to newer versions of node. I do think that it's nice that installation of global modules requires elevated context.

Cameron Howey

The npm_cache is already in the user's folder. This is actually the more critical folder for npm. If the intention is to share modules between users on the same computer, then both npm_cache AND node_modules should be in Program Files.

Personally I feel it is more "Windows 7-ish" to keep npm_cache in the user's folder, and to put global node_modules in %appdata%.

If you are creating a node.js app, then you should install modules local to that app, which will then run fine from any user that can access that app's directory.

isaacs
Owner

@piscisaureus Ok, I'm fine with it either way. The tricky thing would be that %appdata%\npm isn't in the %Path%, so if you npm install vows -g, then you won't be able to run vows afterwards.

Can we update the MSI to add %appdata%\npm to the %Path% as well?

Bert Belder

Actually I am more for installing into the user folder.

(Yes I know I change my opinion all the time. I should run for president.)

Bert Belder

Now that we're at it, npm-cache should not go into the user's root folder. Stuff it in %appdata%.

isaacs
Owner

The question of where npm defaults the cache and global prefix on windows for a manual install really should be an npm issue, not a node issue.

Nothing here makes me think that we should change where the msi-installed npm gets dropped, especially since you probably do want that updated if you update node.

The problem I see with putting it in %appdata% is that the whole point of global installs is to install things that can be used from the command line. If %appdata%\npm isn't in the %Path%, then it's not a good choice as a default, but of course, all that's configurable pretty easily.

We could always have the MSI modify the %Path% to put %appdata%\npm there, in front of %ProgFiles%\node.

klovadis

Correct me if I'm wrong, but my npm installs also failed when I used the command prompt and npm with administrator privileges. Only after manually granting write permissions for the nodejs folder to the current user npm ran successfully. Afaik by default you need elevated permissions (granted i.e. during the installation procedure) to write into the Program Files folder.

isaacs
Owner

Someone needs to write sudo for windows ;)

How about this as a plan:

  1. Leave the npm default global prefix as it is, and have the msi drop npm into the same folder as node, as we're doing now.
  2. Write prefix = <whatever> to %ProgFiles%\node\node_modules\npm\npmrc
  3. Add <whatever> to the %Path% environ in front of %ProgFiles%\node.

The effect of this will be:

  1. Global installs will work out of the box, without elevated perms, and will add things to the command line path, but will not be requireable.
  2. npm install npm -g will fetch a newer version of npm, which will override the node-installed one, so self-update will work.
  3. Installing a new version of node will install a new builtin version of npm.
  4. Manually dropping npm in the same folder as node.exe will work as it does now, so people who don't use the MSI don't have to do anything special.

Does that meet everyone's needs?

Cameron Howey

What do you mean, "Write prefix = <whatever> to %ProgFiles%\node\node_modules\npm\npmrc"? Is that the npm config file? It doesn't seem to exist in my installation.

Otherwise, I think it's a good solution. The <whatever> should be %appdata%\nodejs or some such.

isaacs isaacs referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
isaacs isaacs referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
isaacs isaacs referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
isaacs isaacs referenced this issue from a commit
isaacs isaacs npm 1.1.0-alpha-5
Fix #2186
First part of #2207
6176461
isaacs
Owner

Fixed in v0.6 branch, publishing very soon.

isaacs isaacs closed this
Alex Wolfe alexkwolfe referenced this issue from a commit in alexkwolfe/node
isaacs isaacs npm 1.1.0-alpha-5
Fix #2186
First part of #2207
e513ac9
Alex Wolfe alexkwolfe referenced this issue from a commit in alexkwolfe/node
isaacs isaacs Re #2207 Add default npmrc for MSI install 4600796
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.