1

当我想构建反应时出现波纹管错误(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",
        ....
};

任何人都可以帮忙吗?

4

1 回答 1

1

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

于 2019-06-26T05:55:05.577 回答