Registry / node-jsx

node-jsx

JSON →
library0.13.3jsnpmunverified

node-jsx is a module designed to enable transparent `require()` of JSX files directly within Node.js environments. Published over a decade ago, its primary function was to transpile JSX syntax on-the-fly using Facebook's jstransform (an early JSX processing tool) so that Node.js could execute `.jsx` files without a prior build step. The package, currently at version 0.13.3, has been officially superseded by modern build pipelines involving tools like Babel, Webpack, Vite, or TypeScript's built-in JSX transformation capabilities. Its last known update was in April 2015, indicating it is no longer maintained. Modern JavaScript and React development workflows universally rely on dedicated transpilers and bundlers for JSX processing, making `node-jsx` an obsolete solution incompatible with contemporary ecosystems.

npm install node-jsx
INSTALL
IMPORT
SIG · NODE-JSX
N
node-jsx
javascriptv0.13.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

install
require('node-jsx').install();
import { install } from 'node-jsx';
This package is CommonJS-only and exposes its functionality directly via `require()`. There is no ES Module equivalent.
installWithOptions
require('node-jsx').install({ extension: '.jsx', harmony: true });
const jsx = require('node-jsx'); jsx.install({ ... });
While functional, chaining `.install()` directly on the `require()` call is the idiomatic usage shown in its documentation.

Demonstrates the deprecated method of installing `node-jsx` to enable on-the-fly JSX transpilation for `require()` calls in Node.js, highlighting its obsolescence.

const path = require('path'); const fs = require('fs'); // Install the node-jsx require hook require('node-jsx').install({ harmony: true }); // Imagine a simple JSX component file at src/MyComponent.jsx // const React = require('react'); // module.exports = function MyComponent({ name }) { return <div>Hello, {name}!</div>; }; // This package is for JSX transpilation only, it does not include React itself. // Trying to require modern React or a JSX file directly will likely fail // due to incompatibilities and missing React runtime. This example demonstrates // the setup, but requires a legacy React setup to actually run JSX. // For demonstration, let's pretend a legacy React is available. // In a real modern scenario, this setup is completely obsolete. console.log('node-jsx require hook installed. This setup is highly deprecated.'); console.log('Modern projects use Babel/TypeScript for JSX transpilation.');
Debug
Known issues
breakingThis package is officially deprecated and completely unmaintained since 2015. It is incompatible with modern React versions (>=0.14) and contemporary JavaScript/JSX syntax.
fix
Migrate to a modern build setup using Babel (with @babel/preset-react) or TypeScript (with 'jsx' compiler option) and a bundler like Webpack or Vite. For server-side rendering, pre-transpile components or use `@babel/register` (for older Babel) or `ts-node` (for TypeScript) with appropriate configurations.
affects: >=0.14.0
breakingThe `harmony: true` option mentioned in its README for ES6 transforms is severely outdated and will not correctly process modern ES6+ or JSX features (e.g., Fragments, Hooks, spread attributes).
fix
See the general fix for deprecation: use modern transpilers that support current ECMAScript and JSX specifications.
affects: >=0.13.0
gotchaThis package exclusively supports CommonJS (`require()`) and cannot be used with ES Modules (`import`). Node.js projects using ES Modules will not be able to utilize this hook.
fix
If your project uses ES Modules, this package is fundamentally incompatible. Use modern build tools that natively support ES Modules and JSX transformation.
affects: *
gotchaUsing `node-jsx` for on-the-fly transpilation in production Node.js applications will incur significant performance overhead, as every `require()` of a JSX file involves a parsing and transformation step.
fix
Always pre-transpile JSX files to plain JavaScript using a build step before deploying to production. Runtime transpilation should only be considered for development environments, and even then, modern alternatives offer better performance and compatibility.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'react/lib/ReactContext'
Attempting to use `node-jsx` with modern React versions (>=0.14) which changed internal module structures significantly.
fix
Upgrade your JSX transpilation pipeline entirely. `node-jsx` is incompatible with modern React. Use Babel or TypeScript instead.
SyntaxError: Unexpected token '<'
Node.js attempting to parse a `.jsx` file directly without the `node-jsx` hook being correctly installed or because the file type isn't registered for transpilation.
fix
Ensure `require('node-jsx').install()` is executed *before* any `.jsx` files are `require()`d. However, this only applies to the severely outdated setup. For modern projects, this error means your build/transpilation step is misconfigured.
TypeError: Cannot read properties of undefined (reading 'install')
The `require('node-jsx')` call did not return an object with an `install` method. This could be due to a faulty installation or an attempt to use `import` with a CommonJS-only package.
fix
Verify that `node-jsx` is correctly installed (`npm install node-jsx`). Ensure you are using `require('node-jsx').install()` and not `import` syntax.
Upgrade
Version history
0.13.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
node-jsx — npm install node-jsx · libregistry