节点模块中的babel箭头函数错误

时间:2019-06-26 05:04:02

标签: reactjs babel react-native-web

当我要构建时,出现以下错误(node_modules中的错误):

ERROR in ./node_modules/react-native-video/Video.js 54:7
Module parse failed: Unexpected token (54:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   }
| 
>   seek = (time, tolerance = 100) => {
|     if (isNaN(time)) throw new Error('Specified time is not a number');

我将这一部分添加到babel文件中

babel.config.js

module.exports = {
  presets: [
    "@babel/preset-env", 
    '@babel/react',
    "module:metro-react-native-babel-preset"
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-transform-arrow-functions"
  ]
}

和我的webpack

const HtmlWebPackPlugin = require("html-webpack-plugin");
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        loader: "babel-loader",
        ....
};

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

我的Webpack配置未设置为将node_modules文件传递给babel-loader 删除exclude: /node_modules/,