Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
Reactjs driven.js:30491 Uncaught SyntaxError:意外的令牌导入,它引用react js应用程序中的行?_Reactjs_Webpack - Fatal编程技术网

Reactjs driven.js:30491 Uncaught SyntaxError:意外的令牌导入,它引用react js应用程序中的行?

Reactjs driven.js:30491 Uncaught SyntaxError:意外的令牌导入,它引用react js应用程序中的行?,reactjs,webpack,Reactjs,Webpack,在我的react js应用程序中,在网页包编译后,控制台中显示一个错误未捕获语法错误:意外的令牌导入,它引用了bundle.js(输出文件)从“react”导入react 这是参考线及其相邻线 var replaceLocation = exports.replaceLocation = function replaceLocation(location, pathCoder, queryKey) { return updateLocation(location, pathC

在我的react js应用程序中,在网页包编译后,控制台中显示一个错误未捕获语法错误:意外的令牌导入,它引用了bundle.js(输出文件)
从“react”导入react

这是参考线及其相邻线

    var replaceLocation = exports.replaceLocation = function replaceLocation(location, pathCoder, queryKey) {
      return updateLocation(location, pathCoder, queryKey, function (path) {
        if (getHashPath() !== path) replaceHashPath(path);
      });
    };
    /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))

/***/ }),
/* 282 */
/***/ (function(module, exports) {

    import React from 'react';
    import WatchableStore from 'watchable-store';
    import { CSSTransitionGroup } from 'react-transition-group';

    import './animate.css';
    import './styles.css';

我不知道发生了什么,我是新来的。。。提前感谢

错误指向
import
关键字。ES6模块不能在浏览器环境中工作,所以您需要使用(用于webpack)将ES6不支持的代码编译成ES5代码

您需要至少使用以下预设设置
.babelrc
文件:

{
  "presets": ["es2015", "react"]
}
然后在webpack.config加载程序中:

{
  test: /.jsx?$/,
  exclude: /node_modules/,
  loader: 'babel-loader'
}

下面是关于这个话题的一个例子。您可以自己找到更多信息。

错误指向
import
关键字。ES6模块不能在浏览器环境中工作,所以您需要使用(用于webpack)将ES6不支持的代码编译成ES5代码

您需要至少使用以下预设设置
.babelrc
文件:

{
  "presets": ["es2015", "react"]
}
然后在webpack.config加载程序中:

{
  test: /.jsx?$/,
  exclude: /node_modules/,
  loader: 'babel-loader'
}
下面是关于这个话题的一个例子。你可以找到更多的自己