Registry / serialization / slice2js

slice2js

JSON →
library3.7.110jsnpmunverified

slice2js is the official Slice-to-JavaScript compiler from ZeroC, part of the Ice RPC framework. It compiles Slice IDL files into JavaScript proxy and skeleton code for building networked applications. The current stable version is 3.7.110 (Ice 3.7.x series). Release cadence follows Ice releases, approximately every 6-12 months. Key differentiator: it's the native compiler for Ice's JavaScript mapping, tightly coupled with the @zeroc/ice npm package. Alternatives like protobuf or Thrift require separate toolchains.

npm install slice2js
INSTALL
IMPORT
SIG · SLICE2JS
S
slice2js
serializationjavascriptv3.7.110
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
const slice2js = require('slice2js'); slice2js.compile(['File.ice']);
import { compile } from 'slice2js';
slice2js is a CommonJS module; no ESM export. Use require() only.
sliceDir
const slice2js = require('slice2js'); const dir = slice2js.sliceDir;
const { sliceDir } = require('slice2js');
sliceDir is a property of the default export, not a named export.
default (require)
const slice2js = require('slice2js');
import slice2js from 'slice2js';
slice2js is CommonJS-only; ES6 import does not work.

Demonstrates how to import slice2js, compile a Slice file, handle exit codes, and access the built-in Slice include path.

const slice2js = require('slice2js'); const path = require('path'); // Compile a Slice file const child = slice2js.compile(['Hello.ice'], { cwd: '/path/to/slice', stdio: 'inherit' }); child.on('close', (code) => { if (code !== 0) { console.error(`slice2js exited with code ${code}`); process.exit(code); } else { console.log('Compilation succeeded'); } }); console.log('Ice Slice directory:', slice2js.sliceDir);
slice2js --version
Debug
Known issues
breakingslice2js v3.8 drops support for Node.js <14 and changes the compiler API.
fix
Upgrade to Node.js >=14 and adjust code for any API changes.
affects: >=3.8.0
breakingslice2js v3.7.0 removed the '--ice' option; Ice includes are now automatic.
fix
Remove '--ice' from args. The sliceDir property provides the path if needed.
affects: >=3.7.0 <3.8
deprecatedThe compile function returns a ChildProcess; consider using promises with child_process.execFile.
fix
Wrap compile in a promise or use child_process.execFile for simpler error handling.
affects: all
gotchaslice2js must be installed in the same project as @zeroc/ice to ensure compatible versions.
fix
Install both as dependencies: npm install slice2js --save-dev && npm install @zeroc/ice
affects: all
gotchaRelative paths in args are resolved from the current working directory, not from the Slice file location.
fix
Use absolute paths or set the 'cwd' option in the second argument to compile().
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'slice2js'
slice2js is not installed or not in node_modules.
fix
Run 'npm install slice2js --save-dev' in your project directory.
TypeError: slice2js.compile is not a function
Incorrect import: using default import with ESM syntax.
fix
Use const slice2js = require('slice2js'); instead of import.
slice2js: error: unknown option '--ice'
The --ice option was removed in slice2js 3.7.0.
fix
Remove --ice from the arguments; Ice includes are added automatically.
slice2js: error: Can't open file './Hello.ice'
File path is relative to the current working directory, not the Slice file location.
fix
Use an absolute path or set the cwd option: slice2js.compile(['Hello.ice'], { cwd: __dirname }).
Upgrade
Version history
3.7.110latest on npm
Audit
Dependencies
@zeroc/icerequiredRuntime Ice library required to use compiled JavaScript proxies/skeletons.
Agent activity
13 hits · last 30 days
node
6
OpenAI (training)
1
Resources
slice2js — npm install slice2js · libregistry