Installing Node.js - Pros / Cons of Using Brew Against Manual Control?

So, I'm looking for information on what pros and cons control the node.js package that was installed manually using homebrew. Besides the obvious advantages of using brew for you all (as opposed to using nvm to update node), are there any real problems or potential conflicts that should be considered when managing somethings with brew and others manually? (or via npm, nvm, etc.?)

+8
npm homebrew nvm
source share
4 answers

My situation for application interpreters like node.js (or python or ruby, etc.) is that:

  • I have many projects, sometimes dozens and dozens.
  • Each project is either moderately or closely associated with a specific version of the interpreter
    • for example, node v0.8.x or v0.10.24 is required
  • Installing these interpreters throughout the system encourages interaction between projects, so I am updating node because project8 is ready to upgrade and break project3.

Given these limitations, I set my own interpreters for each project, because for me the presence of stability and decoupling is more important than other factors, such as reducing disk space requirements.

homebrew is great for agnostic tool projects like ag , git etc., as well as relatively stable other things like postgresql or mysql or mongodb. But for the actual runtime of the interface, the clutch is too tight, so I do not use homebrew for this.

Installing a node is just loading and extracting a tarball so frankly you don't need fancy tools. However, I have a project called wallah that can help with this. You can also watch nvm and envirius

+9
source share

To update npm , you need to run npm update npm -g . Where -g stands for global.

Knowing that if you want to update the global packages installed on your system, you run npm update -g

If you did not add -g when running npm update , it will try to update the local node packages (also known as your current $PWD directory). To find out if you have packages installed in the local directory, you can run npm list , which will return the following if none of them are installed.

 /your/current/directory/ └── (empty) 

If you have node packages in this folder, you will see something like this. (note: This is what was returned when I ran npm list -g )

 /usr/local/lib └─┬ npm@1.4.7 β”œβ”€β”€ abbrev@1.0.4 β”œβ”€β”€ ansi@0.2.1 β”œβ”€β”€ ... 

You can also run brew update && brew upgrade && brew doctor to make sure everything is up to date.

My advice on the first question is to use brew , because it will save you a lot of headaches in the long run, because it can manage almost everything that you install on your computer. Take a look at https://github.com/nicolashery/mac-dev-setup to find out how they set up their development computers.

Make sure you look at https://github.com/phinze/homebrew-cask so you can install applications through brew cask <app you want> .

The biggest reason to use brew for node is that it installs nodes and npm at the same time, it uses the path $(brew --prefix) , but still has its place in /usr/local/ . You still use the same commands as you if you install it through the installation of the package. However, you can really remove node and npm by simply running brew uninstall node , which you cannot do with other ways to install it.

Hope this helps.

PS: If you already have a node installed in another way, then sudo chown $USER /usr/local/* is your friend. All this allows you to read and write access to all folders and files in /usr/local/ , which are necessary only to fix links for brew.

+7
source share

Some people report that npm update does not work on its own (npm cannot update npm) if installed via Brew.

I would suggest installing it manually, since NPM will manage node.js updates and packages, while Brew will only manage node.js + npm, but not modules. Brew is also often behind in updates.

+3
source share

The following are some of the benefits or advantages of homebrew over manual installation of node js

  • When installing node through the installer, you need sudo permission to correctly install or remove packages. sudo allows the installer to place files in areas of your file system that are accessible only to administrators. One good thing about Homebrew is that it does not require access to admin areas for your computer only, so that to install NodeJS
  • After installing node through the installer, you need to add the path to the node executable to your $ PATH.where system, as in the case of homebrew, it will take care of this task.

One of the benefits out of the box is to help web developers install some of the missing Mac packages.

0
source share

All Articles