I have a AWS EC2 instance containing a CentOS (atleast that's what I think) and I followed this link(How to yum install Node.JS on Amazon Linux) to install nodejs on my instance (the second answer).The thing is I am able to install it successfuly and even able to run the following commands
node --version
v8.11.1
npm --version
5.6.0
node -e "console.log('Running Node.js ' + process.version)"
Running Node.js v8.11.1
But I have a python file that runs a node command through python's subprocess module.This the python file below
import json
import yaml
import subprocess
def output_filter(json_data, exp):
json_data = json.dumps(json_data)
result = subprocess.check_output(['node', '/home/ec2-user/api-demo/jstest3.js', json_data, exp])
dict = yaml.load(result.decode("utf-8"))
filtered_output = json.dumps(dict)
return json.loads(filtered_output)
Below is my jstest3.js file
var args = process.argv.slice(2);
//console.log(args[0]);
var jsonata = require("jsonata");
var data = JSON.parse(args[0]);
var expression = jsonata(args[1]);
var result = expression.evaluate(data);
console.log(result);
I basically uses a nodejs library called jsonata
to do some JSON parsing.I am able to use execute this python file in my local machine (I have an Ubuntu 16.10 x86_64) without any issues.But when I execute this in my aws instance
, this is the error I get
result = subprocess.check_output(['node', '/home/ec2-user/api-demo/jstest3.js', json_data, exp])
File "/usr/lib64/python3.5/subprocess.py", line 316, in check_output
**kwargs).stdout
File "/usr/lib64/python3.5/subprocess.py", line 383, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib64/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.5/subprocess.py", line 1289, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'node'
Why am I getting this error despite node being installed in my aws instance as shown above?What am I doing wrong?