Resolution nodejs fs eacces

I ran into a strange problem while reading the fs file.

I have a node application running from the deployment manager (strongloop solid-pm) as the following user: "pm-pm".

No matter what permissions I give the file, I try to open the node application, I get

return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); worker:1 Error: EACCES, permission denied '/root/my_dir/file.txt' at Object.fs.openSync (fs.js:432:18) at Object.fs.readFileSync (fs.js:286:15) 

I tried everything:
sudo chown -R strong-pm:strong-pm /root/my_dir
sudo chmod -R 777 /root/my_dir
sudo chmod 777 /root/my_dir/file.txt
adding strong-pm to the group
then adding this group to the directory ...

Still out of luck .. any ideas?

Thanks!


System: Ubuntu 14.04 x64 on DigitalOcean

+6
source share
1 answer

Instead of trying it inside the node, try switching to this user and reading the file:

 su strong-pm cat /root/my_dir/file.txt 

If this works, make sure that node is working with this user.

+1
source

Source: https://habr.com/ru/post/979754/


All Articles