How do I run a nodejs file using ./foo.js instead of node foo.js from the terminal? Running it with node works fine, but with the ./ I get bash: ./foo.js: Permission denied.
I’m new to Ubuntu, so I’m not sure if its an OS tweak.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Make sure the file is executable. You can check this by doing a “ls -la”:
The lack of an “x” means that it’s not executable. To make it executable, use
chmod +x:Also make sure you have a “shebang” line at the very top of the file. This tells the shell what interpreter to use for the file: