Node For Mac Os X

Here’s how I get productive for JavaScript/Node on Mac OS.

If you read one of my earlier posts on how to install Node.js, you probably noticed there are quite a few ways to install it on your computer.This could be from a package manager, from the source code, or from a pre-compiled binary distribution. Nov 07, 2016 Install node.js for macOS or Windows. Node-RED supports node.js 0.10.x or later. It is recommended to use the LTS (long-term maintenance) version of node.js. Get and install node.js 4.x LTS that matches your platform. Max OS X: Universal. Currently I am using Node.js v0.6.16 on Mac OS X 10.7.4. Now I want to upgrade it to the latest Node.js v0.8.1. But after downloading and installing the latest package file from nodejs.org, I found that system is still using v0.6.16 instead of v0.8.1 when I typed 'node -v' in a terminal.

It includes iTerm2, zsh, Node, Visual Studio Code and some git commands.

Table of Contents
Mac

Setup iTerm2

  • Install iTerm2

Change edit mode to natural text

  • iTerm Preferences → Profiles → select your profile → Keys tab → Load Preset… → Natural Text Editing (See this StackOverflow answer)

New session should start where previous left off

  • iTerm Preferences → Profiles → select your profile → General tab → Working Directory section → Reuse previous session’s directory option

Quit on tab close

  • iTerm Preferences → General, “Closing” → “Quit when all windows are closed”

Increase font size

  • iTerm Preferences → Profiles → select your profile → Text tab → Font section → Change font → Update font in the popup
  • Fan of 16pt Monaco (12, 14 is just too small)

Enable infinite history

  • iTerm Preferences → Profiles → select your profile → Terminal tab → Unlimited scrollback

Shell setup

zsh

With oh-my-zsh manager. Sets you up with auto-completion.

snazzy colour theme

Using iterm-snazzy, which is a case of downloading the .itermcolors file and choosing the theme from (iTerm Preferences → Profile > Colors > Color Presets…).

Pure prompt

It’s simple, clean but gives you enough information to be productive.

(see Setup and configuration for how to get Node/npm up and running)

  • Install using npm: npm install --global pure-prompt
  • Initialise by adding the following to your .zshrc:

As a developer it’s always good to have a few browsers and tools handy:

  • Google Chrome: still a goto due to its solid and extensive dev tools. Usually I install the React or Vue dev tools.
  • Postman for Mac: to manually test APIs
  • Firefox: number 2 browser
  • Brave: auto-blocks ads and tracking, sort of the “play” browser, its dev tools are a buggier/less ergonomic version of Chrome dev tools (this is because Brave uses Chromium under the hood)
  • Safari - installed by default on Mac OSX, it’s a buggy browser, good to test using it since it surfaces weird SVG and cookies security policy quirks. Since it’s the default it’s also widely used by non-technical people.
    • Enable the dev tools: Safari → Preferences → Advanced → Show develop menu in menu bar.

I use Visual Studio Code, it strikes the right balance between usable out of the box and customisable. The way I see it editors like vim or Atom need a bit of config before being productive, and others like Sublime or IDEs (WebStorm) don’t have the same plugin ecosystem.

Installing Node-RED on macOS or Windows, auto startup with ...

Install VSCode command line tools

Open the dialog using CMD + P.

Use: Shell Command: Install 'code' command in PATH

The VSCode command line tool usage examples:

  • code . : open . directory in VSCode
  • code -r . : replace directory opened in VSCode with the current directory
  • code -a . : add current directory to VSCode, ie. initialises a workspace

Must-have extensions

  • Atom keymap: I’m not a fan of the default keybindings, this uses Atom-style ones, get it from the Visual Studio Marketplace or ext install atom-keybindings from CMD + P menu
  • EditorConfig for VS Code: “EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.” (see editorconfig.org), ie. helps you deal with tab size, trimming spaces etc. across code editors, get it here from the Visual Studio Marketplace or ext install EditorConfig from CMD + P menu

Nice to have extensions

  • ESLint: “Integrates ESLint JavaScript into VS Code.”, get it from the Visual Studio Marketplace or ext install vscode-eslint from CMD + P menu
  • npm Intellisense: “autocomplete npm modules in import statements”, get it from the Visual Studio Marketplace or ext install npm-intellisense from CMD + P menu
  • Snazzy theme: same colour theme (snazzy) as I’ve got setup for the terminal for VSCode, get it from the Visual Studio Marketplace or ext install snazzy theme
  • Import Cost: “Display import/require package size in the editor”, get it from the Visual Studio Marketplace, or ext install import-cost

Not many productivity apps, just Alfred, which I use as a better Spotlight Search and Clipy which is a clipboard manager.

Maccy

A simple clipboard manager designed for OSX.

It works out of the box better than Clipy (see below).

Install it through Homebrew:

Update the preferred hotkey to CMD + shift + v:

Paste by default on selection of a clipboard item:

Superseded by Maccy Clipy

Bump up the number of “inline items” (Clipy → Preferences → Menu → Number of items place inline).

Node.js - Where Should My Npm Modules Be Installed On Mac OS ...

Set your screenshots to save to clipboard + enable the option to paste as plain text (Clipy → Preferences → Beta → Paste as PlainText + Save screenshots in history).

Update Xcode using xcode-select--``install.

Install Homebrew for package managements (think apt or pkg for Mac):

Install Node.js either from source, using the Mac installer or using Homebrew:

Install n – Interactively Manage Your Node.js Versions using npm (now that we have Node installed):npm install--``global n

Switch to latest Node version using n:sudo n latest

Install jq (format and deal with JSON nicely in the terminal) and watch (run a command repeatedly) using Homebrew

Add a few git extensions:

  • git-open: “Type git open to open the GitHub page or website for a repository in your browser.” using npm install --global git-open
  • git-standup: “Recall what you did on the last working day.” using git standup, there are multiple install options (see git-standup#install), I usually go with: brew install git-standup
  • git-lg: simpler/prettier git log:

Add the following minimal .vimrc, which enables syntax highlighting, has basic tab/tabsize configuration and enables line numbers display:

Set up SSH keys and add to VCS hosting, see this GitHub help article:

  • Generate a new key: ssh-keygen -t rsa -b 4096 -C '*[email protected]*'
  • Copy your public key to clipboard so you can paste it wherever your hosted Version Control system asks you to: pbcopy < ~/.ssh/id_rsa.pub

Put percentage on power level, right-click the battery indicator and select “Show Percentage”.

❤️ Spotify

More at my /uses page.

(Optional) Docker, VirtualBox

Docker is a containerisation technology, think VMs but smaller. I recommend Docker for Mac.VirtualBox allows you to run Virtual Machines on Mac, install it at VirtualBox downloads.

Get The Jest Handbook (100 pages)

Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.

or

Join 1000s of developers learning about Enterprise-grade Node.js & JavaScript

Follow me on twitch!

Since node.js is the new cool kid on the block, I want to write a really short introduction how to install it on Mac OS X and start playing with it.
Exploring technologies is something I try to fit in my everyday, that’s why I’m choosing the verb playing. This little and quick guide is really more for everyone who has more experience with PHP than with ruby or python. I don’t even want to talk to you ruby on rails people, you know how all this stuff works, shoo!

See more resultsNode

Homebrew

Not only for node.js, but a powerful tool that every developer on Mac OS should have or have heard of: homebrew. So head on and install it, because it allows you to install node.js with one command (Terminal phobics, don’t worry, it’s short!) and gets you going on setting up your testing environment.

Getting node.js

To install node.js on your machine, you simply type:

That’s it. You watch a short process of download and build, which has not failed the couple of times I’ve tried it on both Mac OS 10.6 and 10.7, but don’t close that Terminal quite yet.

Running node.js

For running node.js you actually need to run a process in your shell or make something run the process for you. For now, we’ll stick to having the Terminal window open.
How to Node has a very comprehensive guide how to send output to a browser, by making node start an http server and listen for requests. Requests, as in every web capable programming language are important in node.js and you’ll be hearing a lot more about this request object in the future.

So what you don’t need to do is to define a directory, like you know from apache or lighttpd servers. You can create a node project in any folder on your system, go there in a Terminal window and run your .js file with node filename.js, followed by hitting ENTER.

Example:

Let’s say we wanted to use the hello world example, we’d shamelessly copy paste the code into our text editor and save it in a folder called nodetests. Now with the Terminal we type something like:

Now we have a running node server on the specified port, that will output Hello World on a specified address. You can see the output by pointing your browser to http://localhost:3000 and it should say: Hello World.

Going back to your editor and changing some lines will have absolutely no effect right now, because node does not check for file changes by default. So even if your file would now output `Hello Moon`, the node server still thinks that it should output `Hello World`, because it was that the last time it checked.

To prevent you from undergoing the horrible task of changing to your Terminal window, pressing

See Full List On Treehouse.github.io

every time you make a change you want to preview, there actually is a way to skip that.

How To Install Node JS On Mac OS? - PositronX.io

Using node-dev instead of node, automatically restarts your server, whenever it notices a file changed. That’s way cooler and feels a lot more like developing PHP suddenly. It’s not bad to feel a little at home when you start on frighteningly seeming complex stuff like node.js.

NPM: the node package manager

Remove Node Mac Os X

NPM is what apt is for debian or gem for ruby. It’s the universal tool for getting stuff and also packing stuff up in neat and reuseable modules.
Taking a look at the amazing list of modules available and also their own repository site, you will quickly understand why you will want to use it.
By simply typing

you’ll install an hmvc framework, make it available for your project and also have the frameworks own tools for debugging, running servers or similar at hand.

Node.js community

I have not personally met anyone who actually has developed with node, but I’ve recently infected another developer with it.
Although I have joined the IRC channel, because I was stuck on some typical node.js beginner issues like correct use of callbacks and understanding how to prevent node.js from spawing 84 processes on resizing 18.8MP images with the imagemagick module. If you don’t watch out, you’re going to do more stuff parallel than you actually intend to and definitely more than your Mac Book Pro can handle without crashing (seriously).
Especially spion helped me and actually restructured some of my code for my understanding, which was pretty amazing of him, also looking at the things he actually has published. Kudos to him.

Thank you for reading! If you have any comments, additions or questions, please leave them in the form below! You can also tweet them at me

If you want to read more like this, follow me on feedly or other rss readers