“意外的令牌<”尝试运行节点服务器时

时间:2016-03-06 04:24:22

标签: javascript node.js reactjs npm babeljs

在我对react-server-examplehttps://github.com/mhart/react-server-example的改编中,我似乎无法使用JSX 。我已经做了一些更改(比如用Webpack替换Browserify等等),然而,在广泛浏览并安装babel-present-react之后,我似乎无法弄清楚我为了运行应用而缺少的东西。

的package.json

{
  "name": "react-server-example",
  "version": "1.1.5",

...

  "dependencies": {
    "babel-preset-react": "^6.5.0",
    "react": "^0.14.7",
    "react-dom": "^0.14.7"
  },
  "devDependencies": {
    "babel-cli": "^6.6.5",
    "babelify": "^7.2.0",
    "webpack": "^1.12.14"
  }
}

Errors when trying to run node

webpack.config.js

module.exports = {
    entry: "./entry.js",
    output: {
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" },
            { test: /\.js$/, loader: "jsx-loader" },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel",
                query:
                  {
                    presets:['react']
                  }
            }
        ]
    }
};

.babelrc

{
  "presets": ["es2015", "stage-0", "react"]
}

1 个答案:

答案 0 :(得分:-1)

应该是:

render: function() {
    return (
      <Test name="wassuppp" />
    );
  }

您似乎错过了返回的开头(