Could not find a JavaScript runtime for Ruby

If you running rake and getting similar error:

$rake db:create
rake aborted!
Could not find a JavaScript runtime. See for a list of available runtimes.
(See full trace by running task with --trace)

I have tried to install execjs using gem install execjs but it doesn’t solve my issue. But rather that, directly install nodejs directly solve the issue.

$sudo apt-get install nodejs