Skip to content

Instantly share code, notes, and snippets.

@rosszurowski
Last active March 16, 2023 09:54
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 rosszurowski/eee05cebb67fd869b7db1914b844db9c to your computer and use it in GitHub Desktop.
Save rosszurowski/eee05cebb67fd869b7db1914b844db9c to your computer and use it in GitHub Desktop.
Modifying $PATH in Make on macOS
# You can, in fact reference node_modules without the prefix by prepending node_modules to your $PATH with this line:
export PATH := ./node_modules/.bin:$(PATH)
# But for some reason, on macOS, Make doesn’t recognize the $PATH when it’s the start of a command.
# So this rule doesn’t work. It treats `prettier` as a file/directory:
format: node_modules
@prettier --write .
# But this rule does:
format: node_modules
@true && prettier --write .
# Erring on the side of simplicity and clarity, it's probably best to just include the full prefix.
@nebbles
Copy link

nebbles commented Mar 16, 2023

Oo interesting. This is the top of the Makefile I ran:

SHELL=bash
export REACT_APP_GIT_HASH := $(shell git rev-parse HEAD)
export PATH := ./node_modules/.bin:$(PATH)

I'm using stock make, but a bit older

GNU Make 3.81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment