Registry / devops / js-sql

js-sql

JSON →
library0.0.3jsnpmunverified

js-sql is a transpiler that allows you to embed SQL directly in JavaScript code using JSX-like template syntax (<sql>...</sql>). It supports variable interpolation, parameter placeholders ($1, $2...), and function calls inside SQL blocks. The current stable version is 0.0.3, and it appears to be in early development with no recent updates. It differentiates itself by offering compile-time SQL embedding without runtime string concatenation, but it is unmaintained and lacks type safety or modern tooling integration.

npm install js-sql
INSTALL
IMPORT
SIG · JS-SQL
J
js-sql
devopsjavascriptv0.0.3
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.

jss
npx jss -x jss src/ build/
require('js-sql') or import from 'js-sql'
js-sql is a command-line tool, not a runtime library. Use the CLI directly.
.jss files
Use .jss file extension and compile with jss
Using .js file extension without compilation
The package compiles .jss files, not standard .js files.

Transpile a .jss file containing SQL template tags into plain JavaScript using the jss CLI.

// Create a file example.jss function getUser(id) { var sql = <sql> SELECT * FROM users WHERE id = $1 </sql>; return sql; } // Transpile: npx jss -x jss . out/ // Output example.js will contain: // function getUser(id) { // var sql = "SELECT * FROM users WHERE id = " + id; // return sql; // }
Debug
Known issues
deprecatedPackage is unmaintained and no longer compatible with modern Node.js versions.
fix
Use a modern SQL query builder like knex.js or sequelize.
affects: >=0.0.3
gotchaThe <sql> tags are transpiled at build time, not runtime. Dynamic SQL strings are not supported.
fix
Ensure all SQL statements are static within <sql> tags; use placeholders for parameters.
affects: *
gotchaPlaceholder indexes ($1, $2) are not validated and may lead to SQL injection if user input is interpolated directly.
fix
Always use placeholders for user input; avoid inserting variables directly with {}.
affects: *
breakingThe package depends on outdated esprima and jstransform packages which have known security vulnerabilities.
fix
Consider using a maintained alternative; do not use this package in production.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'jstransform'
Missing dependency, or npm install failed to install peer dependencies.
fix
Run npm install in the package directory, or install js-sql with its dependencies: npm install js-sql esprima jstransform
SyntaxError: Unexpected token <
Attempting to run a .jss file directly with Node.js without transpilation.
fix
Compile the .jss file first using: npx jss -x jss input.jss output.js, then run output.js
jss: command not found
js-sql is not installed globally or npx is not available.
fix
Install globally: npm install -g js-sql, or use npx: npx jss [options]
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
esprimarequiredJavaScript parsing for transpilation
jstransformrequiredAST transformation to replace SQL tags with JavaScript
Agent activity
8 hits · last 30 days
node
8
Resources
packagejs-sql
js-sql — npm install js-sql · libregistry