Skip to content
This repository

node.js should install npm (one-liner removed from npmjs.org) #13024

Closed
benatkin opened this Issue June 25, 2012 · 13 comments

5 participants

benatkin Adam Vandenberg Forrest L Norvell Isaac Z. Schlueter Sébastien Lavoie
benatkin

Since this decision was made, http://npmjs.org/ has IIRC changed so it no longer provides the simple instruction to install npm (curl http://npmjs.org/install.sh | sh). This to me indicates that installing npm with node is the preferred way to do it, not just one of two equally valid options.

So I think that in the interest of making installing node/npm easy for beginners, so they can run coffee, lessc, etc, the node formula should install npm.

The node.js configuration option --without-npm should be exposed to users of the Homebrew recipe so it can still be installed the old way.

Forrest L Norvell

+1.

Unless @isaacs thinks otherwise, current practice with Node seems to couple the npm version to the Node version it's installed with.

Isaac Z. Schlueter
isaacs commented June 25, 2012

Yes, I agree.

However, it should not be crippled. Please let me know the ways in which "just let it install" results in a bad scene from homebrew's pov, and I'll tell you how to make it not bad. Everything should be possible to configure into a state you can be happy with. (If we made it work with Debian and Windows, we ought to be able to make it work with Homebrew ;)

Sébastien Lavoie

Yes, I agree.

However, an option should be provided: --without-npm

benatkin

@lavoiesl absolutely. Updating the issue text.

Sébastien Lavoie

Also, I would add a caveat explaining that npm was installed, remember the user to update and remove it manually if needed.

Isaac Z. Schlueter
isaacs commented June 26, 2012

@lavoiesl Why not just remove it if the brew is removed, or update it when the brew is updated?

If you want the things that npm installs to go in a different place (including updates to npm itself) then that can be accomplished with a npmrc file placed in npm's install root. (Ie, /path/to/lib/node_modules/npm or some such.) and those configs will be "sticky" whenever npm installs a new copy of itself globally. There's no need to regexp replace the default configs this time around :)

Sébastien Lavoie

I am not sure I understand everything you are saying.

Is it a typo ? Why not just remove it if the brew is removed

Also, updating node.js != updating npm

Isaac Z. Schlueter
isaacs commented June 26, 2012

Yes, typo, fixed, sorry :)

Also, updating node.js != updating npm

Why not? That's kind of the point of this request. These days, most node users only get npm updates when they update node, and expect npm and node to be installed at the same time. Eventually, they might not even be separate programs, but that's a ways off.

Sébastien Lavoie

I started to work on a PR, but I saw the comment pointing to #8784. Should I understand your position has changed since then because npm is becoming more tightly linked to node ?

Sébastien Lavoie

Well if we use the npm provided by the npm package, then yes is may be updated at the same time.

Sébastien Lavoie lavoiesl referenced this issue from a commit June 26, 2012
Commit has since been removed from the repository and is no longer available.
Isaac Z. Schlueter
isaacs commented June 26, 2012

@lavoiesl Yes, but it's also changed because there are approved and supported methods to set the rules that Homebrew wanted npm to follow, without crippling functionality or introducing bugs.

For example, by default, npm will install executables to {prefix}/bin, man pages to {prefix}/share/man, and node module libraries to {prefix}/lib/node_modules. Last we visited, it was made clear that Homebrew considers this bad behavior, since it manages those folders, and npm should instead put stuff in something like {prefix}/share/npm/{lib,bin,man} or something.

In order to get it to follow these rules, the previous npm recipe:

  1. did not use the same install method for npm that most other node users would use (and which I maintain and keep up to date).
  2. made code changes to some npm internals that caused subtle bugs, and much wailing and gnashing of teeth.

There is an approved and supported way to do these things now: An ini-formatted config file named npmrc, placed in the root of npm's source tree where it's running (I believe that would be something like {prefix}/Cellar/node/0.8.0/lib/node_modules/npm/npmrc or something?) and tell it to set whatever configs necessary. It would be good to add caveats to add your desired global bin path to the PATH, but that's not hard.

That file should probably contain something like prefix = {prefix}/share/npm or something. (Replace {prefix} with the Homebrew prefix, that is. Not a literal mustache variable thing.)

If the user manually updates to a new copy of npm, eg via npm install npm -g, then (in this proposed configuration), it'll install npm with a binary at {prefix}/share/npm/bin/npm, linked to a module at {prefix}/share/npm/lib/node_modules/npm, and then copy that config file into the new npm, so that it'll continue to behave the same way. If the user ever wants to go back to using the Homebrew-installed npm, they can do npm rm npm -g, and they'll be left with that.

This is essentially how we've made things work with the MSI installer on Windows, and it's how a few different Linux distros are doing things. It's proven to be a very flexible arrangement. Users can update manually if they want, and that works, or they can roll back easily, etc.

Sébastien Lavoie lavoiesl referenced this issue from a commit June 26, 2012
Commit has since been removed from the repository and is no longer available.
Sébastien Lavoie

Thanks a lot for your reply @isaacs, at least now I understand.

I invite you to go check my PR #13053 and review the changes.

Adam Vandenberg
Owner
adamv commented June 29, 2012

Move the discussion to #13053.

Adam Vandenberg adamv closed this June 29, 2012
Sébastien Lavoie lavoiesl referenced this issue from a commit July 24, 2012
Commit has since been removed from the repository and is no longer available.
Sébastien Lavoie lavoiesl referenced this issue from a commit July 24, 2012
Commit has since been removed from the repository and is no longer available.
Sébastien Lavoie lavoiesl referenced this issue from a commit in lavoiesl/homebrew June 26, 2012
Sébastien Lavoie [node] Added option --without-npm, installing npm by default. Closes #…
…13024.

[node] Adds a (lib + "node_modules/npm/npmrc") with prefix "#{share}/npm" so npm doesn’t conflict brew. See #13024

[node] minor rewording, as suggested by @isaacs

[node] removed global = true, as suggested by @isaacs

[node] Changed npm prefix from /usr/local/Cellar/node/*/share/npm to /usr/local/share/npm

[node] check for external npm installation before allowing node to install with npm

[node] Changed exception when external npm is installed to a Requirement

[node] moved unless ARGV.include? '--without-npm' to the depends_on instead of the Requirement
e98deb6
Max Howell mxcl referenced this issue from a commit June 26, 2012
Sébastien Lavoie Install npm by default
Closes #13053. Refs #13024.

Adds option "--without-npm".

Signed-off-by: Max Howell <mxcl@me.com>

Fixed merge. Amended some user-facing texts.
1e70950
John Calsbeek Nexuapex referenced this issue from a commit June 26, 2012
Sébastien Lavoie Install npm by default
Closes #13053. Refs #13024.

Adds option "--without-npm".

Signed-off-by: Max Howell <mxcl@me.com>

Fixed merge. Amended some user-facing texts.
0b08683
lucha controesempio referenced this issue from a commit September 06, 2012
Commit has since been removed from the repository and is no longer available.
ckdaas referenced this issue from a commit in ckdaas/homebrew June 26, 2012
Sébastien Lavoie Install npm by default
Closes #13053. Refs #13024.

Adds option "--without-npm".

Signed-off-by: Max Howell <mxcl@me.com>

Fixed merge. Amended some user-facing texts.
fce7593
Tai Chi Minh Ralph Eastwood raedwulf referenced this issue from a commit September 10, 2012
Commit has since been removed from the repository and is no longer available.
Charlie Sharpsteen Sharpie referenced this issue from a commit in Sharpie/homebrew June 26, 2012
Sébastien Lavoie Install npm by default
Closes #13053. Refs #13024.

Adds option "--without-npm".

Signed-off-by: Max Howell <mxcl@me.com>

Fixed merge. Amended some user-facing texts.
0e0aec1
Shazron Abdullah shazron referenced this issue from a commit in shazron/homebrew June 26, 2012
Sébastien Lavoie Install npm by default
Closes #13053. Refs #13024.

Adds option "--without-npm".

Signed-off-by: Max Howell <mxcl@me.com>

Fixed merge. Amended some user-facing texts.
a532b2c
Matthew Rothenberg mroth referenced this issue from a commit in mroth/pivotal_workstation November 23, 2012
Matthew Rothenberg no longer compile custom npm
Since Homebrew/homebrew#13024 , homebrew node includes npm built in to be
in-line with the default node install.  Therefore, no longer necessary
to do a custom compilation of npm, easier to let homebrew manage and not
deal with duplicates.
1826dbc
Matthew Rothenberg mroth referenced this issue in pivotal/pivotal_workstation November 23, 2012
Merged

no longer compile custom npm #119

Sharethrough Workstation strworkstation referenced this issue from a commit in sharethrough/pivotal_workstation November 23, 2012
Matthew Rothenberg no longer compile custom npm
Since Homebrew/homebrew#13024 , homebrew node includes npm built in to be
in-line with the default node install.  Therefore, no longer necessary
to do a custom compilation of npm, easier to let homebrew manage and not
deal with duplicates.
2740137
snakeyroc3 snakeyroc3 referenced this issue from a commit in snakeyroc3/homebrew June 26, 2012
Sébastien Lavoie Install npm by default
Closes #13053. Refs #13024.

Adds option "--without-npm".

Signed-off-by: Max Howell <mxcl@me.com>

Fixed merge. Amended some user-facing texts.
3829055
Jeff Saracco jeffsaracco referenced this issue from a commit in jeffsaracco/pivotal_workstation November 23, 2012
Matthew Rothenberg no longer compile custom npm
Since Homebrew/homebrew#13024 , homebrew node includes npm built in to be
in-line with the default node install.  Therefore, no longer necessary
to do a custom compilation of npm, easier to let homebrew manage and not
deal with duplicates.
87ee03a
Sean Nolen dissonanz referenced this issue from a commit in dissonanz/sprout November 23, 2012
Matthew Rothenberg no longer compile custom npm
Since Homebrew/homebrew#13024 , homebrew node includes npm built in to be
in-line with the default node install.  Therefore, no longer necessary
to do a custom compilation of npm, easier to let homebrew manage and not
deal with duplicates.
5139fff
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.