I downloaded the latest versions of Emscripten, Python, Ninja, CMake, and OpenCV, and ran the following command
emcmake python ./opencv/platforms/js/build_js.py build_js
Error
configure: python ./opencv/platforms/js/build_js.py build_js '-DCMAKE_TOOLCHAIN_FILE=E:\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake' -DCMAKE_CROSSCOMPILING_EMULATOR=E:/emsdk/node/22.16.0_64bit/bin/node.exe -G Ninja
EMSCRIPTEN/EMSDK environment variable is not available. Please properly activate Emscripten SDK and consider using 'emcmake' launcher
usage: build_js.py [-h] [--opencv_dir OPENCV_DIR] [--emscripten_dir EMSCRIPTEN_DIR] [--build_wasm] [--disable_wasm]
[--disable_single_file] [--threads] [--simd] [--build_test] [--build_perf] [--build_doc]
[--build_loader] [--clean_build_dir] [--skip_config] [--config_only] [--enable_exception]
[--cmake_option CMAKE_OPTION] [--build_flags BUILD_FLAGS] [--build_wasm_intrin_test]
[--config CONFIG] [--webnn]
build_dir
build_js.py: error: unrecognized arguments: -G Ninja
emcmake: error: 'python ./opencv/platforms/js/build_js.py build_js '-DCMAKE_TOOLCHAIN_FILE=E:\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake' -DCMAKE_CROSSCOMPILING_EMULATOR=E:/emsdk/node/22.16.0_64bit/bin/node.exe -G Ninja' failed (returned 2)
It seems the issue is related to Emscripten not having the environment set up correctly, but my environment passed the verification from Emscripten’s official documentation. I hope someone can help.