Not sure how you execute the code. Try the following steps.
Create a file containing the source code, in this case easy.erl, which you already have:
[g@somecomp:~/test]$ cat easy.erl
-module(easy).
-author("var").
%% API
-export([add/2]).
add(X, Y) ->
X + Y.
Now compile the module:
[g@somecomp:~/test]$ erlc easy.erl
Launch Erlang and load it from the shell:
[g@somecomp:~/test]$ erl
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.2.1 (abort with ^G)
1> l(easy).
{module,easy}
In the shell, execute the function and close Erlang:
2> easy:add(1,2).
3
3> q().
ok
4> [g@somecomp:~/test]$
(bash, csh), :
[g@somecomp:~/test]$ erlc easy.erl
[g@somecomp:~/test]$ erl -noshell -eval 'io:format("~p~n", [easy:add(1,2)])' -s init stop
3
[g@somecomp:~/test]$