I have a discord bot that I made and I used to use crontab to have it just restart and update the bot automatically each day at 2 am. At some point recently it stopped working but I don't know why. The script is the following:
#!/usr/bin/bash
echo "Killing application..."
pkill -9 node
echo "Moving to bot dir..."
cd /home/pi/theBot/
git pull
npm install
echo "Starting bot..."
node /home/pi/theBot/bot.js
When I run this manually it works just fine and starts up perfect. When it runs through crontab however, it gets errors presumably related to optional chaining in my node project; it cites a line that goes:
if(msg.mentions?.users?.size > 0) {
I normally run node v14.17.6 but I installed and am using v16.13.0 and npm v8.1.0.