Skip to content

Instantly share code, notes, and snippets.

@maxenglander
Last active January 1, 2016 02:09
Show Gist options
  • Save maxenglander/8077886 to your computer and use it in GitHub Desktop.
Save maxenglander/8077886 to your computer and use it in GitHub Desktop.
Master Programming Course

Topics

  1. Installing Node.js on Mac OS X with Brew
  2. How does the Node.js search path work?
  3. How do I decide whether to install something locally or globaly?
  4. Look at OSC code
  5. Look at Andy Hall's Photoshop code
  6. Bare minimum Photoshop plugin

Installing Node.js on Mac OS X with Brew

Screencast

  1. Open terminal
  2. Type brew install node

How does the Node.js search path work

Loading modules from node_modules folders Loading modules from global folders

When you invoke the require() command in a Node.js program, e.g.

var bk = require('buttkiss')

Node.js will search for the buttkiss module using the following algorithm

  1. If the buttkiss is a native module, Node.js will just load it - you probably don't need to know any more than that
  2. Node.js will search for the buttkiss module in ./node_modules/
  3. Node.js will search for the buttkiss module in ../node_modules/
  4. Node.js will continue searching for buttkiss in the node_modules folder by traversing upwards in the filesystem hierarchy
  5. If the $NODE_PATH environment variable is set, then Node.js will search the paths delimited in that environment variable
  6. Node.js will also search in $HOME/.node_modules, $HOME/.node_libraries, $PREFIX/lib/node

How do I decide whether to install something globally or locally?

  1. Any module that a project depends on should be expressed as a dependency in package.json, and will therefore be installed locally when you run npm install
  2. Any module that is not a project dependency can be installed globally, e.g. a tool that watches your project for any filesystem changes and automatically runs your unit tests

Look at OSC code

Screencast

Bare minimum Photoshop plugin

  1. Enable remote connections in Photoshop, using password "password"
  2. Open terminal
  3. cd ~
  4. Download generator-core with git clone git@github.com:adobe-photoshop/generator-core
  5. Download buttkiss with git clone git@github.com:maxenglander/buttkiss
  6. Install buttkiss with cd generator-core; node app ../buttkiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment