Arian Hosseinzadeh Arian Hosseinzadeh - 1 year ago 123
Node.js Question

Getting rid of node-jsx

In the router of my NodeJS app, I want to render a react app. As it is not browserified (and there reactified) it returns

unexpected token <
error while building. I found if I
it doesn't return me this error.
is deprecated. Is there any way to build the project without requiring it ?

var JSX = require('node-jsx').install(),//as we don't reactify it while building
React = require('react'),
Board = React.createFactory(require('../components/board')),
DataStore = require('../store/store');

var router = require('express').Router();

router.get('/', function(req, res) {
var initialState = {'users': DataStore.getUsers()};
var markup = React.renderToString(
res.render('board', {
markup: markup,
state: JSON.stringify(initialState),
layout: 'boardLayout'

module.exports = router;

Answer Source

node-jsx has been deprecated in favor of babel. Instead of require('node-jsx').install();, you can now userequire('babel/register');.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download