Installing NodeJS on MacOS - rajivkanaujia/alphaworks GitHub Wiki

Background

Ran into issues due to having many versions of node, npm etc. So I wrote a bash script to take care of the installation. I use Homebrew for most of my installations unless brew does not have it. I have added several other modules/packages that I need for my development.

Some of the manual commands used for a clean machine are mentioned below. Web search these to learn more about them Basic stuff

    $ brew install -g node
    $ brew install -g nvm
    $ brew install -g npm
    $ npm install -g npm-update-all
    $ npm install -g --save-dev typescript
    $ npm install -g --save-dev eslint eslint-config-google

Other optional items

    $ brew install -g yarn
    $ brew install -g webpack
    $ npm install -g express-generator
    $ npm install -g serverless
    $ npm install -g serverless-aws-documentation
    $ npm install -g serverless-offline
    $ npm install -g --save-dev lambda-local
    $ npm install -g xmlhttprequest

Script

    #!/bin/bash

    # remember to add execute privileges to sh via chmod +x

    echo "updating brew"

    brew cleanup
    brew update
    brew doctor
    brew upgrade
    mkdir ~/.nvm
    mkdir ~/.bower
    mkdir ~/.npmrc
    mkdir ~/.npm
    mkdir ~/.node-gyp
    mkdir ~/.node_repl_history

    brew reinstall -g node
    brew reinstall -g nvm
    brew reinstall -g npm
    brew reinstall -g yarn
    brew reinstall -g webpack
    npm install -g express-generator
    npm install -g serverless
    npm install -g serverless-aws-documentation
    npm install -g serverless-offline
    npm install -g --save-dev lambda-local
    npm install -g xmlhttprequest
    npm install -g --save-dev typescript
    npm install -g --save-dev eslint eslint-config-google
    npm install -g npm-update-all

    echo 'Done installing!'

Note: If you like the instructions here, please refer it on your posts/documentation. Contact me if there are corrections needed.