solc-js v1.0.1 is a cross-browser JavaScript bindings for the Solidity compiler, using Emscripten-compiled solc binaries from the solc-bin repository. It is designed as a smaller and faster alternative to the solc package for browser-only environments, while solc or solc-native are recommended for Node.js. It provides an async API to fetch compiler versions, compile Solidity source code, and resolve imports. It has a moderate release cadence and is maintained as part of the ethereum-play project on GitHub.
npm install solc-jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Import solc-js, fetch available versions, load a specific compiler, and compile a simple Solidity contract.
Use ESM imports (`import solcjs from 'solc-js'`) or dynamic import in Node.js.
Access `.version` from the `solcjs` module itself: `const { version } = await solcjs(version);` is incorrect; use `const compiler = await solcjs(version);` and check compiler.version if needed.Always specify a version string to avoid unexpected compiler versions. Use `versions().releases[0]` for stable.
For Node.js, use `solc` or `solc-native` instead.
Switch to ESM imports: `import solcjs from 'solc-js';`
Use `const solcjs = require('solc-js').default;` or upgrade to ESM.Use `const compiler = await solcjs(version); const output = await compiler(source);` correctly.