Node Version Manager step is causing permission denied error during yarn setup

Here is the build url: Bitrise - Mobile Continuous Integration and Delivery - iOS & Android Build Automation

This error started occurring right after one of our team members added the NVM step in our workflow using the Android & Docker, on Ubuntu 20.04

Large stack. The command we’re running is yarn install && yarn allow-scripts and it used to work when we added a step to modify the node_modules folder permissions by using chmod -R 777 node_modules but this is not longer working since the NVM step was added. Here is the important part of the log:

Error: command failed
    at ChildProcess.<anonymous> (/bitrise/src/node_modules/@npmcli/promise-spawn/index.js:64:27)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:322:12) {
  cmd: 'sh',
  args: [
    '-c',
    'node_modules/.bin/patch-package; node_modules/.bin/rn-nodeify --install events,stream,vm,assert,https,http,os --hack'
  ],
  code: 126,
  signal: null,
  stdout: '',
  stderr: '/tmp/yarn--1685547024439-0.8984727713775877/node: 3: exec: /root/.nvm/versions/node/v18.14.1/bin/node: Permission denied\n' +
    '/tmp/yarn--1685547024439-0.8984727713775877/node: 3: exec: /root/.nvm/versions/node/v18.14.1/bin/node: Permission denied\n',
  event: 'postinstall',
  script: 'node_modules/.bin/patch-package; node_modules/.bin/rn-nodeify --install events,stream,vm,assert,https,http,os --hack',
  pkgid: '',
  path: '/bitrise/src'
}

I have tried other workarounds by applying a trap/catch in the bash script but I still get the same error. I also tried running the commands in the yarn setup manually while using ssh access and they ran without issue. The error only occurs when yarn is trying to run the commands.

Is there a workaround or a fix for this? Thank you for your help.

Just for documentation in case someone else runs into this issue. The node manager step is maintained by the community and the user and group are not set to root. Solution is to either fork the node manager step and adjust it to your needs or figure out another way to manager your node version.