As a minimal mistake Jekyll theme user, I use the following commands to set up and use npm, gem, and bundler for macOS.

npm

Installation / Update

  • Install npm
    $ brew install node
    

    Note: Type node -v and npm -v to validate the installation.

Usage

  • Install packages (based on package.json)
    $ sudo npm install
    
  • Run scripts
    $ sudo npm run build:js
    

Gem and Bundler

Installation

  • Install rbenv and ruby-build
    $ brew install rbenv
    $ brew install ruby-build
    $ brew install ruby-install
    $ ruby-install ruby
    
  • Set environment path
    $ vim ~/.zshrc
    
    ...
    ## rbenv
    export PATH="$HOME/.rbenv/shim:$PATH"
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
    ...
    
  • Install ruby
    # check ruby versions
    $ rbenv install -l
    
    # install ruby
    $ rbenv install 3.1.2
    
    # select ruby
    $ rbenv global 3.1.2
    $ rbenv rehash
    
    # check ruby
    $ rbenv versions
    
    # reload zsh
    $ exec zsh -l
    
  • Install bundler
    $ gem install bundler
    
  • Install dependencies using bundler (based on Gemfile)
    $ bundle install
    
  • Run local jekyll server
    $ bundle exec jekyll serve --host .. --port .. --livereload
    

References

  1. How to install/update/run npm, gem, and bundler for Jekyll-based minimal mistake management)
  2. You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user))

Leave a comment