├── .github └── FUNDING.yml ├── CHANGELOG.md ├── .gitignore ├── LICENSE └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: nijicha 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## April 21, 2022 4 | ### Added 5 | - A guideline to setup `node`, `yarn` via `homebrew` & [`asdf-vm`](https://asdf-vm.com/) 6 | 7 | ### Changed 8 | - Change main branch from `master` to `main` 9 | - Change node version manager from `nvm` to [`asdf-vm`](https://asdf-vm.com/) 10 | - Moved **legacy guideline** version to branch [`legacy-note`](https://github.com/nijicha/install_nodejs_and_yarn_homebrew/tree/legacy-note) 11 | 12 | ## November 13, 2020 13 | - Moved from this [Gist](https://gist.github.com/nijicha/e5615548181676873118df79953cb709) 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Commom 3 | 4 | # IntelliJ project files 5 | .idea 6 | *.iml 7 | out 8 | gen 9 | ### macOS template 10 | # General 11 | .DS_Store 12 | .AppleDouble 13 | .LSOverride 14 | 15 | # Icon must end with two \r 16 | Icon 17 | 18 | # Thumbnails 19 | ._* 20 | 21 | # Files that might appear in the root of a volume 22 | .DocumentRevisions-V100 23 | .fseventsd 24 | .Spotlight-V100 25 | .TemporaryItems 26 | .Trashes 27 | .VolumeIcon.icns 28 | .com.apple.timemachine.donotpresent 29 | 30 | # Directories potentially created on remote AFP share 31 | .AppleDB 32 | .AppleDesktop 33 | Network Trash Folder 34 | Temporary Items 35 | .apdisk 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Nathakorn Chaninthanadecha 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Install NodeJS, Yarn via Homebrew 2 | 3 | ## Notice 4 | > Thank you everyone. For became a stargazers. 5 | > 6 | > I had created this guideline for personal note purpose (first on [Gist](https://gist.github.com/nijicha/e5615548181676873118df79953cb709) and then this repository) 7 | > 8 | > Pull request is available. Please help me contribute this one 😂. 9 | > 10 | > Legacy note (guideline) had moved to branch `legacy-note` 11 | 12 | ## Prerequisites 13 | - [Homebrew](https://brew.sh/) should be installed (Command line tools for Xcode are included). 14 | 15 | ## Getting started 16 | 17 | ### Part A: Install asdf-vm (A parts from official [website](https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies)) 18 | 19 | 1. Install `asdf` via Homebrew. Current `asdf-vm` version is `0.10.0` 20 | ```shell 21 | brew install asdf 22 | 23 | brew install gpg gawk # These are `asdf-nodejs` plugin dependencies 24 | ``` 25 | 26 | 2. Add following line to your profile. (`.profile` or `.zshrc` or `.zprofile`) 27 | 28 | ```shell 29 | # asdf 30 | [ -s "/$(brew --prefix asdf)/libexec/asdf.sh" ] && . $(brew --prefix asdf)/libexec/asdf.sh 31 | ``` 32 | 33 | 3. Close and open your terminal again. 34 | Or Choose one from the following command once for reload your profile. (`.profile` or `.zshrc` or `.zprofile`) 35 | 36 | Example 37 | - `source ~/.profile` 38 | - `source ~/.zshrc` 39 | - `source ~/.zprofile` 40 | 41 | 4. Verify `asdf` is installed 42 | 43 | `asdf version` 44 | 45 | 5. Install `asdf` plugins 46 | 47 | ```shell 48 | asdf plugin add nodejs 49 | asdf plugin add yarn 50 | ``` 51 | 52 | 6. Verify `asdf` and `plugins` are ready! 53 | 54 | ```shell 55 | ❯ asdf list 56 | 57 | nodejs 58 | No versions installed 59 | yarn 60 | No versions installed 61 | ``` 62 | 63 | ### Part B: Install nodejs and yarn 64 | 65 | > **NOTE** 66 | > 67 | > If you are matched to these condition below. [You must install NodeJS v16+ (LTS Gallium)](https://doesitarm.com/app/nodejs/) 68 | > 69 | > - Using Apple Silicon machine ✅ 70 | > - Installed `homebrew` on Native build (homebrew PATH: `/opt/homebrew`) ✅ 71 | > 72 | > Alternatively, If your had configured your **SHELL** to support Homebrew native & Homebrew rosetta2 (e.g. script below like I did) 73 | > You can install `v15` or lower via Homebrew rosetta2. But I prefer to use v16+ (LTS Gallium) 74 | 75 | ```bash 76 | # My .zprofile 77 | 78 | # Apple M1 79 | if [ "$(uname -m)" = "arm64" ]; then 80 | # Use arm64 brew, with fallback to x86 brew 81 | if [ -f /opt/homebrew/bin/brew ]; then 82 | export PATH="/usr/local/bin${PATH+:$PATH}"; 83 | eval $(/opt/homebrew/bin/brew shellenv) 84 | fi 85 | else 86 | # Use x86 brew, with fallback to arm64 brew 87 | if [ -f /usr/local/bin/brew ]; then 88 | export PATH="/opt/homebrew/bin${PATH+:$PATH}"; 89 | eval $(/usr/local/bin/brew shellenv) 90 | fi 91 | fi 92 | ``` 93 | 94 | 1. Install `nodejs` and `yarn` 95 | 96 | Current LTS nodejs version is `16.14.x`, Codename: `Gallium` 97 | 98 | ```shell 99 | asdf install nodejs lts 100 | asdf install yarn latest 101 | ``` 102 | 103 | 2. Set `nodejs` and `yarn` globally for your machine 104 | 105 | ```shell 106 | asdf global nodejs lts 107 | asdf global yarn latest 108 | ``` 109 | 110 | 3. Verify they are installed 111 | 112 | ```shell 113 | ❯ node -v 114 | v16.14.2 115 | 116 | ❯ npm -v 117 | 8.5.0 118 | 119 | ❯ npx -v 120 | 8.5.0 121 | 122 | ❯ yarn -v 123 | 1.22.18 124 | 125 | ❯ asdf list 126 | nodejs 127 | 16.14.2 128 | lts 129 | yarn 130 | 1.22.18 131 | 132 | ❯ asdf current 133 | nodejs lts /Users/nijicha/.tool-versions 134 | yarn 1.22.18 /Users/nijicha/.tool-versions 135 | ``` 136 | 137 | 4. Enjoy! 🥳 ❤️ 138 | 139 | ## Read more 140 | - https://asdf-vm.com 141 | - https://github.com/asdf-vm/asdf-nodejs 142 | - https://github.com/twuni/asdf-yarn 143 | --------------------------------------------------------------------------------