/usr/bin/env: node: Permission denied - node.js

As the title suggests I am receiving the error
/usr/bin/env: node: Permission denied
when trying to run
npm run build
for my react app. The following link is the leadup to this point with all that I've done and tried, not to be included here for the sake of not duplicating questions Error with react-scripts in npm run build.
Additionally, I have viewed this posting, Getting Error /usr/bin/env: node : Permission Denied, and it was unhelpful to me.
Any help is much appreciated.

I was working in a dockerized node environment and noticed that the mounted source code directory had different ownership (running the container as root) from host environment. Changing the ownership using:
chown -R root:root .
made the error go away for me!

The issue ended up being a matter of file ownership. Root was the owner of many things for the project rather than my profile. Simply changed the ownership from root to me.

For me, re-installing node with NVM solved the issue:
Install nvm
nvm install 14
nvm use 14

you should running command as super user sudo npm run build

For anyone else hitting this, there is another avenue of investigation. There might be another factor affecting execute permissions. There's an exec flag on drive mounts to enable script execution (neat safety feature for automounted usb sticks!). So if your code is on a drive that you've mounted, you need that option set to run scripts on it. Tell-tale signs are the permissions on the script being correct (appropriate user, group and execute bits set), but it still complaining about the shebang line (1st line) being the permission denied. Also, if you type mount, you might see noexec set on the mount point where your source code is (it may not show here if exec is set). How your mount is set up varies greatly, but a place to start is your /etc/fstab.

Related

Installing rclone according to the official instructions but permission denied

Noob question, but hear me out
So I installed rclone word-for-word according to this (https://rclone.org/install/)
However, when I got around to rclone config the terminal returned 2020/02/28 11:37:29 Failed to load config file "/home/myUser/.config/rclone/rclone.conf": open /home/myUser/.config/rclone/rclone.conf: permission denied
In an attempt to fix this I ran chmod u+x "/home/myUser/.config/rclone/rclone.conf" which returned chmod: changing permissions of '/home/myUser/.config/rclone/rclone.conf': Operation not permitted
Then I ran the same command prefixed with sudo which seemed to work. Yet after running rclone config again the same permission denied error appeared. What should I do? What did I do incorrectly during install? I just want to be able to run rclone config without having to use sudo.
Unrelated side note I had a similar experience with Anaconda in which I can't run the command for opening the program without sudo but as I ran the command with it the launcher appears with an error message which I can't remember exactly but it ran along the lines of: "Cannot run in sudo mode, please do it again in user mode." Funny Catch-22 if you ask me. I ended up uninstalling it.
Solution: set the permissions of rclone.conf to chmod 777. I changed the whole folder and its files using sudo chmod -R 777 /home/myUser/.config/rclone/ for good measure. Now I can finally retry installing Anaconda.

Sudo is broken on linux mint 17.3

When I execute
sudo apt-get install composer
Following error occurred:
sudo: error in /etc/sudo.conf, line 0 while loading plugin `sudoers_policy'
sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins
and don't know the root password. Please suggest me a solution
Your system is broken. Unless you changed the permission specifically on that file, there's a good chance other files are also affected by the same issue.
If it's just this file for some reason, you can boot from a live CD, mount your root filesystem, and run chmod 0600 /path/to/usr/lib/sudo/sudoers.so.
Otherwise, either you or something you used ran chmod 0777 on your /usr or other directory when it should never happen. Realistically, your best option in this case if to backup your data, reinstall the system and restore. You could attempt recovery, but since you posted this question, it's probably too advanced.

ubuntu backup-manager Permission denied

I've recently installed backup manager onto my ubuntu machine to have automated backup going. The problem is when I go to set up the automatization using this code -
it comes us up saying this "bash: /etc/backup-manager.sh: Permission denied"
I do not understand this error. I've tried change the user who read/writes to someone other than root and that didn't work. I tried changed the chmod number from 770 to 700 and still didn't work.
any info on this is welcome. Thank you to those who help :)
those wondering I am using this tutorial giving to me by the host. https://documentation.online.net/en/dedicated-server/tutorials/backup/configure-backup/start
I'm using the desktop version of ubuntu 16 incase that is needed
The sudo doesn't do what you want in this case. What happens is that the shell evaluates the redirection and attempts to open the /etc/backup-manager.sh for you before the sudo cat even gets started. That fails because the shell still runs as you unprivileged user. You have to say sudo -i to open a new root shell, execute the commands and exit again.
Alternatively you could try sudo nano /etc/backup-manager.sh and paste the contents there. This would work because the editor is run as root and does the file opening itself when you save.

EPERM error when running Gulp as non-root

I'm using Gulp to compile some assets on a simple standalone WordPress theme project.
When I run my gulp task that compiles some LESS files I get the following error:
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: EPERM, chmod '/Users/harryg/Sites/sites/wordpress/wp-content/themes/samarkand-2/assets/css/main.min.css'
When I run it as sudo the task executes without problem.
Thinking it was a permissions error I chmod'd the entire theme folder and its contents to 777 but this doesn't solve the problem. I have gulp installed globally which may be the issue but I'm not sure how to solve.
EDIT
Even if I run the local gulp I get the same error. I.e. running node_modules/.bin/gulp from my project folder produces the same EPERM error.
`sudo chown -R `whoami` sites/wordpress/wp-content/themes/samarkand-2`
should fix it. Or whatever directory you want to start from. This is no dangerous and might come because of you node-installation. It's pretty common and should be fixed in general after running installs with npm#3.X.X
While #cwelske gives a "hacky" workaround in his answer, the link he provides to the bug report provides a nicer fix for Gulp 3: use vinyl-fs.
npm install vinyl-fs --save-dev
Modify your gulpfile to use VFS:
Add to your requires block: var vfs = require('vinyl-fs');
Modify your output pipe: .pipe(vfs.dest('./output'));
The reason I was facing this error is because the files were owned by a more generic group and user so that multiple team members could work on the project together. Obviously Ubuntu doesn't allow you to chmod someone else's files. I suspect the OP is in a similar situation (the web-server might own the files).
If you do not require this kind of setup, your other option is to change the files to be owned by your user, something like:
sudo chown -R me:me .
Setting file permissions to 777 are not going to help you, because unless you own the file, you cannot chmod it without sudo. (Hence it works when you run gulp as sudo.)
gulp 3.x has a bug that makes it want to chown all files regardless if it already has all required permissions or not. It is supposedly fixed in gulp 4.
The linked bug contains a nice workaround if you know that the files have the correct permissions: Simply replace fs.chmod with an empty function in your gulpfile.js:
var fs = require('fs');
if (1) fs.chmod = function (a, b, cb) {
cb(0);
}

pid file disappears after starting pgpool with ubuntu and postgresql

I´ve installed postgresql 9.1 on ubuntu 12.04 with pgpoolII-3.3.3 and pgPoolAdmin
If I try to run pgpool from a terminal with sudo pgpool it seems to start. Viewing ubuntu file explorer I can see how a pgpool.pid file is created at /var/run/pgpool/pgpool.id (this is the path in pgpool.conf)
But after one second the file disappears.
I have tried to change the owner of the directory and the directory permissions but nothing seems to fix it.
If after that I try to stop pgpool wiht sudo pgpool -m fast stop I got an error: Error. pid file not found
It seems like the file is created and suddenly destroyed. I´m wondering why.
If I try to run pgpool from pgPoolAdmin I got this error: pgpool start failed. pgpool.pid not found.
Like other times, it´s maybe and stupid issue and I´m not being able to solve it as i don´t have a high level of knowledge on those systems.
Any idea about what to try?
Xrry Christmas
Solved. I think the problem was caused by a permission problem. After trying
sudo mkdir /var/run/pgpool
sudo chmod 777 /var/run/pgpool
sudo chown postgres/postgres /var/run/pgpool
sudo postgresql service restart
It seems to be working now.
check the tmp directory using ls -la command and delete the file .s.PGSQL.9999 and .s.PGSQL.9898 and restart the server
Upon configuring PgPool-II, I found some documentation explaining that using the default directory /var/run/pgpool for the PID file was a bad idea, for that file could be erased when the service reboots.
The contents of the /var/run directory (including the pgpool
directory) may be removed by the operating system during a reboot. The
/var/run/pgpool directory should NOT be used as the location for the
pgpool.pid file.
The issue seems to occur when using Ubuntu.
So a possible solution would be to store the PID file in a directory named so as to not match the name of a service that could be rebooted. For instance, you could change the pgpool.conf file :
pid_file_name = '/var/run/pgpool4ever/pgpool.pid'
I could not try it on my own as I do not use Ubuntu, but maybe this could help someone facing a similar problem. Although I am not sure that it is very wise to go past basic Ubuntu way of working....

Resources