Error: ENOENT, no such file or directory './assets' - node.js

After setting up koa-static-folder, my image loads great when I test over localhost with http://localhost:3000/assets/myimage.jpg
But after deploying our node code to an Ubuntu server, we get:
Error: ENOENT, no such file or directory './assets'
What's Ubuntu's issue here? Not sure how to resolve this.
The code that is working locally is:
var koa = require('koa')(),
serve = require('koa-static-folder');
koa.use(serve('./assets'));

Sounds like a permission issue (but I could be wrong!) such that the user that node.js is running under does not have access rights to the assets folder. If this is the problem you have to change access permissions to the folder (see chmod) or run node.js as a user that has the access rights.
If the server isn't publicly accessible you could run the application as sudo to verify if it is a permissions problem or not. Note that using sudo is not a long term solution since it is highly irresponsible/unsecure to run the application as the root user.

Related

permission error when trying to run node server in godaddy

im trying to run a nodejs server on godaddy using the cpanel thing. i followed this tutorial, and got to the part where you run the server file. however, the server gives me a permission error.
there may be something wrong with my file structure, or the tutorial may be out of date, as my file structure differed from that in the tutorial. ex: tutorial said to go to /home/username/public_html, but my public_html folder is located on the root folder.
Update:
i just found that i could change file permissions, and enable the execute option on the node file. i'm now getting a segmentation fault error
if you need any extra information, let me know.

Node.js web application => Error: EACCES: permission denied, open '/opt/cpanel/ea-ruby27/root/usr/share/passenger/helper-scripts/error.log'

When I was developing my web application in my VSCode, everything was working perfectly fine. Then I deployed it to my web hosting service and I get this error. Does anyone know how I can fix this issue?
This particular web application (Node.js application) is deployed on a subdomain whereas I have another application on my main domain created with React.js that does not encounter this issue.
This is my first time asking dev questions, so if there's any further information needed, just ask :)
The error on my website
As you see, this is permission error.
If my guess is right, it seems you developed on windows and going to deploy it on Linux server.
Usually, you don't get permission error on windows but on Linux, we often see that kinds of permission errors.
try this
chmod 777 (directory path of log file)
for example, if you are on Ubuntu, and the log file is in "share/log/log.txt"
sudo chmod 777 share/log -R
check this link here

apache2 on ubuntu webserver rejects permission to access any other file than the delivered index.html

I am trying to set up a webserver running on Ubuntu. I have installed Apache and changed the root directory to an other directory within /var/www/. When I copy the index.html provided by Apache to that directory, I can access that file via remote webbrowser. But if I want to use a different index.html file, even really basic ones, I get an error: "Forbidden You don't have permission to access this resource". I have also tried to download that html, alter just a few lines and put it back on to the server with the result that it also shows that error. If I rename the initially provided index.html to index2.html I can still access it. I do not understand how it is possible that only this exact file is working.
I have tried to grant more permissions with Directory and restarted Apache but it won't work. I am rather new to Linux and Apache, can only use the terminal on my webserver and I do not know what else to do. Please help.
Change the permissions on the file, too, not just the folder. Pretty sure this fix it.
For diagnostic correction, allow permission for all by typing:
sudo chmod -R 777 /path/to/index.html

Folder permissions to Nodejs Express + Apache with Proxy

I have a Linux Ubuntu with Apache serving files (PHP app) from "public/" folder. Inside this folder (public/node/), I have a nodejs express running via Apache ProxyPass/ProxyReverse. Everything works. But when I try to upload a file with the nodejs application (a simple/small API) and save to "public/node/fileupload", I got an error:
code: "EACCES"
errno: -13
This directory (and all others inside public/) has 775 permissions, and the user that started the nodejs application (my own user, not root) is at the same group as Apache (www-data).
If I change the public/node/fileupload directory permission to 777, the upload works and the owner of file is the user that started the nodejs express (my own user, as said above). But, you know, set a directory as chmod 777 is not a good choice.
Do you know how can I avoid the use of chmod 777 on "public/node/fileupload" to allow file upload to a configuration like this?
Thank you in advance.

Azure Node hosting file/folder permissions

I have launched my sails.js app to Azure Node.js shared infrastructure.
App does not lift due to file permission. Seems like grunt tasks cannot create
concatenated files in .tmp directory in the root.
I tried to give write access via FileZilla but it did not worked. When ever I try to hit URL
I see file permissions are getting set into default values.
I also did not see any settings to give Folder permissions at Azure Dashboard.
Is there any workaround on this issue?
Error:
** Grunt :: An error occurred. **
------------------------------------------------------------------------ [31mAborted due to warnings.[39m Running "sails-linker:prodJs"
(sails-linker) task[24m Autoinsert script tags in an html file
[33mWarning: ENOTSUP: operation not supported on socket, scandir
'D:\home\site\wwwroot.tmp\public\concat\production.css' [39m
------------------------------------------------------------------------ Looks like a Grunt error occurred-- Please fix it, then restart
Sails to continue running tasks (e.g. watching for changes in
assets) Or if you're stuck, check out the troubleshooting tips below.
[4mTroubleshooting tips:[24m
*-> Are "grunt" and related grunt task modules installed locally?
Run npm install if you're not sure.
*-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
*-> Or maybe you don't have permissions to access the .tmp
directory?
e.g., D:\home\site\wwwroot\.tmp ?
If you think this might be the case, try running:
sudo chown -R YOUR_COMPUTER_USER_NAME D:\home\site\wwwroot\.tmp
According to the error information below, it seems that the sails app default start up for websocket on the port 1337, but the Azure webapp only enable the ports 80 and 443.
Warning: ENOTSUP: operation not supported on socket
There was an SO thread Deploy sails.js to Windows Azure Website that discuss about deploying the sails app on Azure WebApp.
Hope it helps. Best Regards.

Resources