I can't run commands from nodejs as child_process, or read the file system in an electron application with snap package configuration

I have working on an electron desktop application, the app is quite simple its about building a file browser for Linux. From Nodejs apis I use child_process, fs, path, os, and so on. I am using electron-builder to package and build the application. When I build for linux with target like "zip", "deb", "rpm", the application works as expected. But when I compile for snap. I can't run commands like:

const util = require('util');
const exec = util.promisify(require('child_process').exec);
await exec('which code');
.....
await openExternalApp('code -n',  `"${file.path}"`)
.....
async function openExternalApp(cmd, path) {
    const util = require('util');
    const exec = util.promisify(require('child_process').exec);
    await exec(`${cmd} ${path}`);
}
.....

I got an error:

Error: Command failed: which code

at ChildProcess.exithandler (node:child_process:406:12)
at ChildProcess.emit (node:events:390:28)
at maybeClose (node:internal/child_process:1064:16)
at Socket.<anonymous> (node:internal/child_process:450:11)
at Socket.emit (node:events:390:28)
at Pipe.<anonymous> (node:net:687:12) {
killed: false,
code: 1,
signal: null,
cmd: 'which code',
stdout: '',
stderr: ''
}

Error: Command failed: which code

Also in my program when i have to read directories of the file system related with hard drive or another location simply i can't. I've started to study a little bit the docs in snap store and I realized that you have to configure the slot, layout and slugs to access the whole file system, and perhaps to run bash or shell command like the one above.

After several configuration i continue with the same issues. Here is my configuration for snap in pakage.json

 "snap": {
  "plugs": [
    "desktop",
    "desktop-legacy",
    "home",
    "x11",
    "unity7",
    "browser-support",
    "network",
    "gsettings",
    "opengl",
    "block-devices",
    "classic-support",
    "hardware-observe",
    "home",
    "system-backup",
    "system-observe",
    "process-control",
    "hostname-control",
    "removable-media",
    {
      "system-files": {
        "read": [
          "/etc",
          "/usr",
          "/home",
          "/media",
          "/mnt",
          "/var",
          "/temp",
          "/opt",
          "/sys",
          "/dev",
          "/bin",
          "/snap"
        ],
        "write": [
          "/home",
          "/mnt"
        ]
      }
    }
  ],
  "desktop": {
    "Encoding": "UTF-8",
    "Icon": "${SNAP}/icon.png"
  }
}

snap image config in pakage.json

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum