'Yarn permission denied on Eleastic Beanstalk?

I'm trying to deploy an app from a node monorepo on Elastic Beanstalk and seem to be stuck.

I've installed yarn in my environment and trying to run a build command (custom command using a task monorepo task runner):

Procfile

web: yarn turbo run start:server

In my server logs I'm seeing a lot of permission denied errors:

May  2 20:25:42 ip-172-31-32-247 web: yarn run v1.22.18
May  2 20:25:42 ip-172-31-32-247 web: $ /var/app/current/node_modules/.bin/turbo run start:server
May  2 20:25:42 ip-172-31-32-247 web: mkdir /var/app/current/node_modules/.cache: permission denied
May  2 20:25:42 ip-172-31-32-247 web: ERROR  yarn.lock: mkdir /var/app/current/node_modules/.cache: permission denied
May  2 20:25:42 ip-172-31-32-247 web: error Command failed with exit code 1.
May  2 20:25:42 ip-172-31-32-247 web: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I think these errors are due to my enviroment trying to install the packages as a non-root user. With npm you seem to be able to add a .npmrc file with unsafe-perm=true to your root folder and get it to work. With yarn however, this does not seem to work.

I don't seem to fully understand what is happening and why I'm seeing these errors and am very thankful for any help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source