Search code examples
node.jspm2udev

PM2 App gets permission denied when printing


I have a running pm2 application, the application's method for printing fails with EACCES: permission denied, open /dev/sopa_printer0 However if manually execute the application with node it prints without issues. The printer is /dev/sopa_printer0

From pm2 logs:

Print failed Print failed: Error: EACCES: permission denied, open '/dev/sopa_printer0'

From the command line: node server.js it prints correctly.

Any idea where I can start to debug?

node version 10.0.0
npm version 6.0.0
pm2 version 2.10.3

I added my user to lp group with:

sudo adduser $USER lp

cat /etc/group | grep -i lp
lp:x:7:imagineing

imagineing is my user

$ ls -alh /dev/sopa_printer0
lrwxrwxrwx 1 root root 7 May 26 12:35 /dev/sopa_printer0  -> usb/lp0
$ ls -alh /dev/usb/lp0
crw-rw---- 1 root lp 180, 0 May 26 12:35 /dev/usb/lp0

Solution

  • Finaly I fixed my issue. I added 777 to the /dev/usb/lp0 device (I think others combinations will work but the app is now working)

    $ ls -al sopa_printer0
    lrwxrwxrwx 1 root root 7 May 26 12:35 sopa_printer0 -> usb/lp0
    $ ls -al usb/lp0
    crwxrwxrwx 1 root lp 180, 0 May 26 12:35 usb/lp0