systemd in nextjs


in EC2 my repo, I manually typed

yarn set version stable
yarn db:deploy
yarn build

I could ping EC2 public ip to view my web app

But when I use systemd cd /home/ec2-user/repo && yarn && yarn db:deploy && yarn build && yarn start It always fail

asked 17 days ago61 views
1 Answer


It's hard to understand what you are trying to achieve, but if you like to create a unit file for systems which will start your nextjs application you can use this as template and this as step by step instructions.

Hope it helps

profile picture
answered 17 days ago
  • The problem I am facing is that when I ssh to the instance, and type 'yarn', the command is found, but when used in script in systemd, or ApplicationStart in codedeploy, it always complain yarn: command not found.

  • It could be because yarn is intalled in the homedir of specific user and systemd is trying to run it from the different user.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions