11

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.

ABadOmelette
  • 151
  • 1
  • 1
  • 10

5 Answers5

12

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!

Raaka
  • 304
  • 1
  • 3
  • 15
3

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.

ABadOmelette
  • 151
  • 1
  • 1
  • 10
1

For me, re-installing node with NVM solved the issue:

DaWe
  • 1,422
  • 16
  • 26
0

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.

FokeyJoe
  • 81
  • 5
-2

you should running command as super user sudo npm run build