Permission To Access A Node-Windows Microservice To Files

28 Views Asked by At

I developed a server in node with express, however I want it to deploy when I start my PC, so I installed node-windows, to create a microservice that runs when Windows starts, everything works fine, however the server tries to open any file (image, pdf, or any other) shows me the error depslegarlo por consola si accesa a los archivos node:fs:584 handleErrorFromBinding(ctx); ^

Error: EPERM: operation not permitted, open 'G:\Mi unidad\Sistema de Gestión de Calidad COS en revision y actualizacion\IMPLEMENTACIÓN\2020\GESTION DE INFRAESTRUCTURA\Inventario\Usuarios\1.png' at Object.openSync (node:fs:584:3) at Object.readFileSync (node:fs:452:35) at bufferimagen (file:///C:/Users/USER/Documents/full-stack-inventario/Servidor-Inventario/helpers/copiarCarpetasArchivos.js:257:20) at consultarUsuario (file:///C:/Users/USER/Documents/full-stack-inventario/Servidor-Inventario/controllers/controllersUsuarios.js:189:34) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { errno: -4048, syscall: 'open', code: 'EPERM', path: 'G:\\Mi unidad\\Sistema de Gestión de Calidad COS en revision y actualizacion\\IMPLEMENTACIÓN\\2020\\GESTION DE INFRAESTRUCTURA\\Inventario\\Usuarios\1.png' }

and also this other one

Node.js v19.3.0 Ha ocurrido un error: EPERM: operation not permitted, open 'G:\Mi unidad\Sistema de Gestión de Calidad COS en revision y actualizacion\IMPLEMENTACIÓN\2020\GESTION DE INFRAESTRUCTURA\Inventario\EM\EM0001\169602676450943.jpeg'

The problem is essentially one of permissions, I accept this because when deploying the server via console it works correctly This is the code with which I install the microservice

const path = require('path');
const { config } = require('dotenv');
const { Service } = require('node-windows');

// Cargar variables de entorno desde el archivo .env
config();
// Configurar el servicio de Windows
var svc = new Service({
  name: 'ServidorInventario',
  description: 'Servicio ejecuta el servidor de la APP servidor inventario de CLIOF',
  script: path.resolve(__dirname, 'index.js'), // Ruta completa al script principal de tu aplicació
});


svc.on('install',function(){
  svc.start();
});

svc.install();

Has anyone had this same problem or knows how to solve it?

I have tried changing the user who owns the domain, and looked for how to configure the access permissions of the microservice, I did not find much documentation about it.

0

There are 0 best solutions below