{"id":26386,"library":"shelljs-transpiler","title":"shelljs-transpiler","description":"Translate Bash scripts to ShellJS (shelljs) code. Current stable version is 0.2.6, with a pre-1.0 release cadence. It supports both a web interface and a CLI tool `sh2js`. Unlike manual porting, it automates conversion of common Bash constructs to ShellJS API calls. Notable limitations: not all Bash syntax is handled until v1.0; translations may rely on unimplemented ShellJS features. The tool is experimental and community-driven, with limited maintenance.","status":"active","version":"0.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/nfischer/shelljs-transpiler","tags":["javascript","shelljs","shell","bash","convert","source","translate","transpile"],"install":[{"cmd":"npm install shelljs-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add shelljs-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add shelljs-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for the generated output to execute.","package":"shelljs","optional":false}],"imports":[{"note":"CLI tool; no import, use npx or global install.","wrong":"npm run sh2js script.sh output.js","symbol":"sh2js","correct":"npx sh2js script.sh output.js"},{"note":"ESM-only; CJS require may fail or give different result.","wrong":"const { transpile } = require('shelljs-transpiler')","symbol":"transpile","correct":"import { transpile } from 'shelljs-transpiler'"},{"note":"Default export is a function that transpiles source code.","wrong":"const shelljsTranspiler = require('shelljs-transpiler')","symbol":"default export","correct":"import shelljsTranspiler from 'shelljs-transpiler'"},{"note":"Type import if using TypeScript; not a runtime export.","wrong":"","symbol":"ShellJS","correct":"import { ShellJS } from 'shelljs-transpiler'"}],"quickstart":{"code":"import { transpile } from 'shelljs-transpiler';\n\nconst bashScript = 'echo hello; ls -la';\nconst shelljsCode = transpile(bashScript);\nconsole.log(shelljsCode);\n// Output: 'console.log(\"hello\");\\nshell.ls(\"-la\");'","lang":"typescript","description":"Transpile a simple Bash script (echo and ls) to ShellJS code."},"warnings":[{"fix":"File an issue on GitHub with your failing script.","message":"Some Bash syntax may not be handled until v1.0.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Check the output and manually adjust to use existing ShellJS API.","message":"Translated scripts may depend on ShellJS features not yet implemented.","severity":"gotcha","affected_versions":"all"},{"fix":"Use npx to run the latest version or install globally.","message":"The CLI tool `sh2js` is experimental and may change.","severity":"deprecated","affected_versions":"all"},{"fix":"Avoid using plugins until stable.","message":"Plugin system via `--plugins` is experimental and may not work as expected.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade Node.js or use a transpiler like Babel.","message":"Requires Node.js >= 8 for ES6 features.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Simplify the script or report the issue.","cause":"Input Bash script contains unsupported syntax.","error":"SyntaxError: Unexpected token"},{"fix":"Use `import { transpile } from 'shelljs-transpiler'`.","cause":"Incorrect import: using CJS require instead of ESM import.","error":"TypeError: transpile is not a function"},{"fix":"Install globally: `npm install -g shelljs-transpiler` or use `npx sh2js`.","cause":"ShellJS-transpiler not installed globally or not in PATH.","error":"sh2js: command not found"},{"fix":"Check plugin name and ensure it is installed as a npm package.","cause":"Specified plugin name is misspelled or not installed.","error":"Error: Plugin not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}