Skip to content

Instantly share code, notes, and snippets.

@sjparkinson
Last active August 30, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjparkinson/dc707adc392fc77435b71ab68c89f377 to your computer and use it in GitHub Desktop.
Save sjparkinson/dc707adc392fc77435b71ab68c89f377 to your computer and use it in GitHub Desktop.
# To build the application run `make install`.
#
# This target depends on the `node_modules` target.
install: node_modules
# This target depends on a file called `package.json`.
#
# If `package.json` doesn't exist, make complains that you need one! Run `npm init` to generate one.
#
# If `package.json` exists, but `node_modules/` doesn't, make will run `npm install`.
#
# If `package.json` and `node_modules/` exist, make will compare the last time they were both modified.
#
# Then if `package.json` has been modified more recently than `node_modules/`, and because `package.json` is a dependency of `node_modules/` make knows there have been changes and should run `npm install`.
#
# When the modified time of `package.json` and `node_modules/` are the same (or `node_modules/` is more recent), make knows that `node_modules/` is up to date and doesn't need to run `npm install`.
#
# Try running `npm init`, `make install`, and `npm install <some-package>` in diffrent orders and see when `npm install` is run or not.
#
# You can see last modified times to files and folders using `stat <path>`.
#
# The `touch` command will update the last modified time of a file or folder, so see what `touch package.json` and then `make install` does too.
node_modules: package.json
npm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment