I am trying to compile javascript to wasm using Javy. Javy is a JavaScript to WebAssembly toolchain. It takes your JavaScript code and executes it in a WebAssembly embedded JavaScript runtime. I have set up all the build and development environment. But after that when I am trying to Convert javascript code to wasm binary using command
javy index.js -o index.wasm
I am getting error like :
ajit0902@AJITPC:/mnt/c/Users/msi/javy/target/release$ javy index.js -o index.wasm
Command 'javy' not found, did you mean:
command 'java' from deb openjdk-11-jre-headless (11.0.15+10-0ubuntu0.20.04.1)
command 'java' from deb default-jre (2:1.11-72)
command 'java' from deb openjdk-16-jre-headless (16.0.1+9-1~20.04)
command 'java' from deb openjdk-17-jre-headless (17.0.3+7-0ubuntu0.20.04.1)
command 'java' from deb openjdk-8-jre-headless (8u312-b07-0ubuntu1~20.04)
command 'java' from deb openjdk-13-jre-headless (13.0.7+5-0ubuntu1~20.04)
command 'javr' from deb xc3sprog (0+svn795+dfsg-1build1)
Try: sudo apt install <deb name>
Navigate to /javy/target/release directory to generate the WASM Binary and You will have to save your JavaScript source code in this directory as well.
While installing javy you can also install it as a global dependency and then you won't need to navigate to this directory in order to make use of the executable. And then in the command line execute the below command:
./javy index.js -o index.wasm
After executing this command, you will have the WebAssembly Binary in your directory named index.wasm Execute the wasm file, using the following command
echo "10" | wasmtime run index.wasm