Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React ES6 SystemJS-未捕获(承诺中)错误:意外标记<;(…;)_Javascript_Reactjs_Ecmascript 6_Systemjs - Fatal编程技术网

Javascript React ES6 SystemJS-未捕获(承诺中)错误:意外标记<;(…;)

Javascript React ES6 SystemJS-未捕获(承诺中)错误:意外标记<;(…;),javascript,reactjs,ecmascript-6,systemjs,Javascript,Reactjs,Ecmascript 6,Systemjs,我已经通过下面的System.config安装并导入了react和react dom,但我仍然在下面遇到此错误: 未捕获(承诺中)错误:意外令牌意外令牌意外令牌browserify是最佳解决方案(用于生产和开发)-对我来说: 大口喝: 对于使用SystemJS的非生产(速度非常慢): 这将使您从其他单调乏味的开发工作流程中解脱出来。browserify是最好的解决方案(用于生产和开发)-对我来说: 大口喝: 对于使用SystemJS的非生产(速度非常慢): 这将使您从其他单调乏味的开发工作流程中

我已经通过下面的
System.config
安装并导入了
react
react dom
,但我仍然在下面遇到此错误:


未捕获(承诺中)错误:意外令牌
意外令牌
意外令牌browserify是最佳解决方案(用于生产和开发)-对我来说:

大口喝:

对于使用SystemJS的非生产(速度非常慢):


这将使您从其他单调乏味的开发工作流程中解脱出来。

browserify是最好的解决方案(用于生产和开发)-对我来说:

大口喝:

对于使用SystemJS的非生产(速度非常慢):


这将使您从其他单调乏味的开发工作流程中解脱出来。

您的traceur transpiler是否支持jsx开箱即用?您可能缺少react的预设。@Wex
您的traceur transpiler是否支持jsx开箱即用?
可能不支持。我如何配置traceur来支持它?我找不到任何证据表明traceur能够做到这一点。试试巴别塔。@TamasHegedus我现在试着用巴别塔。但是如何用systemjs配置它呢?babel文档写得很差,很烦人@TamasHegedus,用于expressjs应用程序。我不是在开发express应用程序。您的traceur transpiler是否支持jsx开箱即用?您可能缺少react的预设。@Wex
您的traceur transpiler是否支持jsx开箱即用?
可能不支持。我如何配置traceur来支持它?我找不到任何证据表明traceur能够做到这一点。试试巴别塔。@TamasHegedus我现在试着用巴别塔。但是如何用systemjs配置它呢?babel文档写得很差,很烦人@TamasHegedus,用于expressjs应用程序。我不是在开发express应用程序。这是reactjs的
app.js
。这是reactjs的
app.js
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ES2015 Module Example</title>
</head>
<body>
    <script src="lib/system.js"></script>
    <script>
        System.config({
            "baseURL": "src",

            // Set defaultJSExtensions to true so you don't have to use .js extension when importing the es6 module.
            "defaultJSExtensions": true,

            // 'plugin-babel' or 'traceur' or 'typescript'
            transpiler: 'traceur',

            map: {
                'react': './node_modules/react/dist/react.min.js',
                'react-dom': './node_modules/react-dom/dist/react-dom.min.js',
                'traceur': './lib/traceur.min.js',
                'plugin-babel': './lib/plugin-babel/plugin-babel.js',
                'systemjs-babel-build': './lib/plugin-babel/systemjs-babel-browser.js'
            },
        });
        System.import("app.js");
    </script>
</body>
<div id="example"></div>
</html>
import React from 'react';
import ReactDOM from 'react-dom';

var Hello = React.createClass({
    render: function() {
        return <h1>Hello {this.props.name}</h1>;
    }
});

ReactDOM.render(
    <Hello name="World" />,
    document.getElementById('example')
);
npm install --save-dev babel-preset-react
var gulp = require('gulp');

var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');

gulp.task('build', function() {
    // app.js is your main JS file with all your module inclusions
    return browserify({entries: 'src/app.js', debug: true})
        .transform("babelify", { presets: ["es2015", "react"] })
        .bundle()
        .pipe(source('compile.min.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('js'))
        .pipe(livereload());
});

gulp.task('default', ['build']);
<!DOCTYPE html>
<script src="https://jspm.io/system@0.19.js"></script>
<script>
System.config({
  transpiler: 'babel',
  babelOptions: {}
});
System.import('./main.js');
</script>
gulp.task('watch', ['build'], function () {
    livereload.listen();
    gulp.watch('js/*.js', ['build']);
});

gulp.task('default', ['watch']);