cd ~/Library/LaunchAgents
touch com.spotify.daemon.plist
vi com.spotify.daemon.plist
customize & insert following & save and exit vim
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.spotify.daemon.plist</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/raresoft/Documents/spotifyErr.log</string>
<key>StandardOutPath</key>
<string>/Users/raresoft/Documents/spotify.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string><![CDATA[/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin]]></string>
</dict>
<key>WorkingDirectory</key>
<string>/Users/raresoft/Documents/</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>spotify.js</string>
</array>
</dict>
</plist>
<string>
under the <key>WorkingDirectory</key>
specifies the directory to JS script to be run
spotify.js
in this case is the script to be run on startup