问题
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