'/usr/bin/env: node: Permission denied

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.



Solution 1:[1]

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

Solution 2:[2]

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!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DaWe
Solution 2 Raaka