babel arrow functions error in node_modules

我的未来我决定 提交于 2020-06-29 06:07:13

问题


when i want build react the bellow error appear(error in 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');

And i add this section to babel file

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"
  ]
}

and my webpack

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

Can any one help ?


回答1:


my Webpack config is not set up to pass node_modules files to babel-loader remove exclude: /node_modules/,



来源:https://stackoverflow.com/questions/56765512/babel-arrow-functions-error-in-node-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!