Node.js JSX Require Hook

0.13.3 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.');

view raw JSON →