This is because some shells interpret the $
in your hash as special characters referring to variables.
To get around this, surround your hash with quotes:
bash-3.2$ node createHash.js bacon
$2a$10$i.RiIPW5wSSooTHJI6Sl6usKdx94uAmSUZ8489.os9OKLWGcuO6tm
bash-3.2$ node checkPassword.js $2a$10$i.RiIPW5wSSooTHJI6Sl6usKdx94uAmSUZ8489.os9OKLWGcuO6tm bacon
false
bash-3.2$ node checkPassword.js '$2a$10$i.RiIPW5wSSooTHJI6Sl6usKdx94uAmSUZ8489.os9OKLWGcuO6tm' bacon
true