1

I have a Ubuntu Server on DigitalOcean, which hosts some websites. I just built a mean.js stack app on my mac, and I plan to deploy it to production, thus to this existing server.

I followed this link to install node.js and mongodb, etc. Then, rather than cloning the sample app of mean.js, I cloned my own app from the github:

sudo git clone https://github.com/softtimur/myapp.git /opt/myapp
cd /opt/myapp
sudo mkdir public/tmp/
sudo npm install
npm start

Then, in a browser, I entered https://xxx.xx.xx.xx:3000/#/new. On the server side, I got an error:

router.post /mkdir
{ Error: EACCES: permission denied, mkdir 'public/tmp/sAlTI6NDo5NQcO-lAAAA/'
    at Error (native)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: 'public/tmp/sAlTI6NDo5NQcO-lAAAA/' }

This is because in the backend of my app, it tries to create a folder in public/tmp/ by fs.mkdir(...) where fs = require('fs').

So does anyone know to how to give the server this permission?

PS: I also tried to run

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

but it did not help.

SoftTimur
  • 5,630
  • 38
  • 140
  • 292

1 Answers1

1

The issue is that you created public/tmp/ as root:

sudo mkdir public/tmp/

But you're running the app as $USER, which will most likely not be allowed to write to that directory.

To fix:

sudo chown -R $USER:$GROUP public/tmp/
robertklep
  • 198,204
  • 35
  • 394
  • 381