Tolk

raw JSON →
2.0.0 verified Fri May 01 auth: no javascript maintenance

Tolk is a file reader that automatically transpiles files with available transpilers, inlines sourcemaps, and autoprefixes CSS. It uses a zero-dependency approach for transpilers, requiring users to install them separately (e.g., node-sass, babel). The current stable version is 2.0.0. It supports multiple precompilers including LiveScript, Babel, CoffeeScript, Less, Stylus, and more. Key differentiator: no bundled transpiler dependencies, allowing users to choose and install only what they need.

error TypeError: tolk.read(...).done is not a function
cause Tolk returns a promise-like object with `.done()` method; if you try to use `.then()`, it may fail if not chained correctly.
fix
Use .done() instead of .then(), or call .then() on the returned object.
error Error: Cannot find module 'tolk'
cause Tolk is not installed, or installed globally instead of locally.
fix
Run npm install tolk in your project directory.
error Error: No transpiler found for file extension '.jsx'
cause Required transpiler (e.g., babel) is not installed.
fix
Install the transpiler: npm install babel.
gotcha No built-in transpilers: you must install them separately.
fix Install required transpilers, e.g., `npm install babel` for ES6/JSX support.
breaking Promise interface: uses `.done()` instead of standard `.then()` and `.catch()`.
fix Use `.done(success, fail)` or replace with `.then(success, fail)` after wrapping.
deprecated Package has not been updated since 2016; no support for modern tooling.
fix Consider alternatives like gulp-sass or webpack loaders.
npm install tolk
yarn add tolk
pnpm add tolk

Reads a SCSS file, transpiles with installed transpiler, and logs the resulting CSS.

const tolk = require('tolk');
const path = require('path');

// Ensure you have a transpiler installed, e.g., node-sass
// npm install node-sass --save-dev

tolk.read(path.join(__dirname, 'styles.scss')).then(compiled => {
  console.log(compiled.result); // Compiled CSS
}).catch(err => {
  console.error('Transpilation failed:', err.message);
});