I tried several ways to fix my problem and found that adding export CCACHE_COMPILER_TYPE=emcc to my script file can work out
export CCACHE_COMPILER_TYPE=emcc