[node] Added option --without-npm, installing npm by default. Closes #13024 #13053
Conversation
Looking good! @isaacs wrote about another change that should be made before this is ready, though. #13024 (comment) |
Yep, currently working on it |
Then I believe this PR is ready, unless you want me to squash the commits. |
Almost, but not quite, I think:
That should be |
Well, it depends. Setting it to |
Is it expected that updates of node, even minor releases (0.8.x) will require reinstalling all of the npm modules? |
It will also remove all globally installed packages when you upgrade node, though, along with the bin path you've added to your PATH. Let's say you do this, and you follow the caveat and add You also use Then a new version of node comes out, and you do So, you reinstall everything. Surprise! The This is almost certainly not what you want. Alternatively, let's say it's set to |
Also, removing node will still remove npm, since npm itself will be installed along with the node recipe, in |
Oh, I didn’t thought that |
LGTM. Aside/feature request: It'd be nice if homebrew maintained a file with all the "Please set blah blah env to bloo bloo" stuff. Then I could just source it in my bashrc, and continue ignoring caveats :) |
Yes totally. I have a project like this that I wish to start called bash-includes with basically runs scripts, set aliases and append paths. A basic version exists on my computer. I’ll try to remember to poke you if it comes to life :) |
Trying it out, by reinstalling node a couple of times (first with npm already installed, then without npm installed). It's hard being without node on my mac, but at lest I still have it on my VPS and my Linux box! |
I'm getting this, when I try installing with npm already installed, using the installation script:
|
Well, I could test to check if npm installed outside of Would that work for you ? |
Maybe it should detect if npm is already installed and exit out, providing instructions on how to remove it. Also the text should say
Finally I didn't have to change anything to get npm to work, despite the error message appearing. The other files were linked and my npm was current enough that it still worked. |
No, I think it should still install it with the new configuration. Most will want to get a normal install, I think. |
Let me do some more tests |
Help would be appreciated, I don’t know how to test if npm is already installed outside of Brew, but conflicting Brew’s path. Something like checking if |
I think it should print a message if it's installed in |
But how do you differentiate from the one installed by brew on earlier versions ? |
I think the one brew installs will be somewhere else. I'm installing node again to check. |
To clarify: Earlier version means something like 0.8.0 when 0.8.1 is out, right? |
Yeah, your recipe results in it going into Here's what I think it should do: look for npm in the path (with which), and if it's somewhere outside of Cellar, print out this message: The homebrew node recipe now (beginning with 0.8.0) comes with npm. It appears you already have npm installed at <path-to-npm>. To use the npm that comes with this recipe, first uninstall npm with If you would like to keep your installation of |
Explore what we do with Python and pip. |
link https://github.com/mxcl/homebrew/tree/master/Library/Formula/python.rb There is a difference, though - pip itself gets installed in the pip path. OTOH, node installs and links npm in the homebrew path. |
There you go, the magic is this: def external_npm_installed?
path = Pathname.new("#{modules_folder}/npm")
begin
not path.realpath.to_s.include?(HOMEBREW_CELLAR)
rescue Exception => e
false
end
end
|
Now it seems overcomplicated. I think the But I think maybe this feature just isn't worth the complexity. Maybe you should just roll back the previous two commits and go back to where @isaacs said "LGTM". If we add this it should be a separate pull request. |
Not really, it looks cool to me.
And it is only essential to check for |
What @nandub is talking about, is that the url https://npmjs.org/install.sh now returns a 404. I just found this issue while wading my way through 3 or 4 other GH issues. My dotfiles bootstrap.sh does:
but this now fails (since today, it still worked yesterday) because of the 404. So either it's a temporary glitch on the npm website or this pull requests is now needed if we want to still be able to install node through Homebrew and use npm with it. |
On Sat, Aug 11, 2012 at 4:01 AM, Jean Mertz notifications@github.comwrote:
It's a bug. The bug is now fixed. |
Is this pull request good to go? |
GitHub says it needs to be rebased. |
@lavoiesl Rebase? |
Just an suggestion next time a change like this is made. Instead of telling the user after the fact that a change like this was made, it may be better to detect if the user already has npm install and warn them of the change so they can choose if they want npm bundled or not. For people installing node (and by extension npm) for the first time, the execution of I casually dismissed the post-upgrade message and spent a while trying to track down in node and npm where the While I'm making that comment, it'd also be nice if brew supported terminal colors so that important post install messages and warnings could stick out in some color other than the default. |
Running a Link to my shell session: https://gist.github.com/3561067 |
No, it was not supposed to do that, normally it should refuse to install if you have npm installed and ask you to install with I see it failed to link, did you install |
I don't think so. Running |
I had the same problem as @jtokoph with the upgrade failing to link after installing. edit: After doing a |
Closes Homebrew#13053. Refs Homebrew#13024. Adds option "--without-npm". Signed-off-by: Max Howell <mxcl@me.com> Fixed merge. Amended some user-facing texts.
@kgreunke brew un/link only manage symlinks into the Cellar. To everyone: is there anything we can do, clearly this was a poorly considered patch that has caused much user-discomfort and I am upset about it. I am not familiar with npm or node and thus don't know what to do. |
I think the ultimate problem with the patch was the change to the npm modules directory. Had that been left as the default non-brew location, the script could have removed the non-brew installed npm and installed it's own npm and everything would have worked as before. I realize that might not have been the "brew way", but the modules directory can't be put in version specific brew directory anyway, so why move it at all. |
@mxcl I'm not sure it matters much at this point. Anyone who runs into an issue upgrading will ultimately arrive at this discussion with suggested fixes. Any new installations won't have issues. |
@jtokoph I can't agree. People upgrade long after so we really should fix this. |
@jtokoph @mxcl this still has problems with new installs. Previously I didn't have to have npm directly in my path in order to access to certain CLI modules i.e. coffee-script. It's not a big pain to add an additional path, but it seems messy to me. Also, it was annoying to find out that the modules directory had moved. |
@jtokoph much like @MikeMcQuaid , I don't agree with your sentiment. I usually forget to do regular updates, and it's only through pure chance I arrived at this dicsussion. So with that, I ran into this issue last night. I have approximately half as much hair left on my head after much pulling! I could not for the life of me work out where my node modules had gone, or why new modules were being installed at a seemingly new location. I was sure it was my fault since I don't expect breaking changes in minor version increments. Also being a recent migrant to osx compounded things, i was left completely baffled and quite frustrated. Before i came across this thread i managed to work around the issue by setting the prefix in my |
If people could be more verbose with their replies, it would help. For example I have no idea what the default npm module location is, so I can hardly fix this to go back to that. Also I think npm installed binaries should be in the path. It's just ridiculous that they aren't. People keep writing formula that do these sorts of things and it is RIDICULOUS. |
Apologies. It is my understanding that previously the prefix for npm was |
@mxcl That's very good to hear. I can't agree with you more. IIRC, there was some concern about npm putting things directly in the "normal" prefix directories. For example, Earlier versions of this recipe used the prefix A compromise was made to have brew-installed npm use If someone can articulate the exact behavior that is intended, I'll tell you how to make the files and commands line up to make that happen. I'm certainly no homebrew expert, but if Node and npm can't deliver what you need, I'll change them so that they do. |
Since the problem seems squarely focussed around updating node via brew, and people not realising the consequences of this, might it be an option to change the flag to Please tell me to shut up if I'm talking nonsense :-) It's just since I'm, at this point, pretty much a clueless end-user I thought my perspective might be of use |
In my opinion, it seems that the ideal solution would be for things with homebrew to work the same as they would without homebrew, but with the ease of using the commands that homebrew users know.
I'd be happy to take a closer look at this. In the case of upgrading node, it seems liek the issue is that it doesn't preserve npm's homebrew-style configurations. It's an easy change to make it do that, but we should evaluate if it's the most sensible path. Sniffing for whether the user has installed it already or not seems a bit weird to me. |
Reopening since discussion is happening. |
I guess I was wrong, it should still be fixed. But the biggest issue now might be fixing it in a way that doesn't break things again for people that already upgraded. Is that even possible without a giant mess in the |
Closes Homebrew#13053. Refs Homebrew#13024. Adds option "--without-npm". Signed-off-by: Max Howell <mxcl@me.com> Fixed merge. Amended some user-facing texts.
I don’t really see the problem of using npm inside brew.
For those who still prefer using their own npm,
--without-npm
will do the tricknpm uninstall npm
, it will break, and you’ll have to reinstall node to get it back, but it’s asking for it.brew uninstall node
, it will remove node and npm, but npm depends on node, so it’s logical.@isaacs mentionned using a npmrc, but I am not sure how to use it. Guidance is appreciated.
Related issues: [#13024, #8784, #3762]