When writing a react server rendering chestnuts, there was an exception thrown by nodemon compiler server.jsx?

  node.js, question

图片描述


Json file

“scripts”: {

"test": "webpack-dev-server --hot",
 "server":"nodemon server.jsx --exec babel-node"

},


server.jsx
The specific code is

import express from 'express'
 import React from 'react'
 import { renderToString } from 'react-dom/server'
 import {RoutingContext,match} from 'react-router'
 import {Provider} from 'react-redux'
 import * as test from '../../actions/test/testaction'
 import routes from './routes'
 import configureStore from './stores/index.js'
 
 const app=express()
 
 function renderFullPage(html,initialState){
 return (`
 <!  DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8" />
 </head>
 <body>
 <div id="app">
 <div>
 ${html}
 </div>
 </div>
 <script>
 window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};
 </script>
 <script src="index.js"></script>
 </body>
 </html>`
 )
 bracket
 app.use((req, res) => {
 match({ routes, location: req.url }, (err, redirectLocation, renderProps) => {
 if (err) {
 res.status(500).end(`Internal Server Error ${err}`);
 } else if (redirectLocation) {
 Res.redirect (redirect location.pathname plus redirectLocation.search);
 } else if (renderProps) {
 const store = configureStore();
 const state = store.getState();
 
 Promise.all([
 store.dispatch(test.getTestDate())     //store.dispatch(fetchItem(renderProps.params.id))
 ])
 .then(() => {
 const html = renderToString(
 <Provider store={store}>
 <RoutingContext {...renderProps} />
 </Provider>
 )
 res.end(renderFullPage(html, store.getState()));
 });
 } else {
 res.status(404).end('Not found');
 bracket
 });
 });

This is a chestnut that I wrote according to the tutorial, but I don’t know why this mistake occurred.

Visual inspection is lackingbabel-preset-react, check.babelrcRight.