/usr/bin/env: node: Not a directory

When I try to trigger my Jenkins jobs to invoke this "deployproxy" I get this error saying "/usr/bin/env: node: Not a directory".

Please let me know how I can fix this. When I run this cmd on my EC2 it deploy proxy successfully without any errors.


Jenkins Console Output:

+ /apps/opt/node_modules/.bin/apigeetool deployproxy -u <user> -o <org> -e dev -n <name> -p '<password>' -L <URL>
/usr/bin/env: node: Not a directory
Build step 'Execute shell' marked build as failure
Sending e-mails to: <email>
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Notifying upstream projects of job completion
Finished: FAILURE
0 1 1,783
1 REPLY 1

Some installations of Node.js install the node binary as 'nodejs' instead of 'node'. This is one known cause for the error you are seeing. There are some nodejs-legacy system packages that can be installed to help manage this for you. Please note that not always but many times this can be fixed with a symlink from nodejs to node. This means that you can try one of the following approaches:

1. Try creating the symlink:

sudo ln -s "$(which nodejs)"/usr/local/bin/node

2. If that fails, Please consult nodejs.org if the suggestion does not work.