I\'m setting up webpack to my react project using yarn and this error appears:
ERROR in ./src/app.js 67:6 Module parse failed: Unexpected token (67:6) Y
web Failed to compile.
<PATH>/KeyboardAwareHOC.js 13:12
Module parse failed: Unexpected token (13:12)
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 3
| } from ‘react-native’
| import { isIphoneX } from ‘react-native-iphone-x-helper’
import type { KeyboardAwareInterface } from ‘./KeyboardAwareInterface’
|
| const _KAM_DEFAULT_TAB_BAR_HEIGHT: number = isIphoneX() ? 83 : 49
install the below package and restart your expo package.
https://www.npmjs.com/package/@codler/react-native-keyboard-aware-scroll-view
The selected answer missing some details:
It should be test: '/\.(js|jsx)$/'
, replaced with test: /\.js|\.jsx$/
\: is an escape character
in this case for .
|: is an Alternation / OR operand
$: is end of line
Hopefully this is useful for you.
Source: https://www.rexegg.com/regex-quickstart.html
add a .babelrc file to the same folder where your node_modules folder is, with the below content
{
"presets": ["@babel/preset-react"]
}
You are using unnecessary escape character: which is not required.
Replace test: '/\.(js|jsx)$/',
with test: /\.js$|jsx/,
it should work fine.
I replicated your issue in my machine and found the same which is resolved by the above fix.
hope this helps, happy coding!!!
This error happened to me simply because the file was placed in the parent folder of the project (i.e. outside the project's folder).
Moving the file to the appropriate folder fixed it.