You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."

前端 未结 5 1884
独厮守ぢ
独厮守ぢ 2021-02-05 11:02

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

相关标签:
5条回答
  • 2021-02-05 11:15
    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

    0 讨论(0)
  • 2021-02-05 11:22

    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

    0 讨论(0)
  • 2021-02-05 11:25

    add a .babelrc file to the same folder where your node_modules folder is, with the below content

    {
      "presets": ["@babel/preset-react"]
    }
    
    0 讨论(0)
  • 2021-02-05 11:28

    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!!!

    0 讨论(0)
  • 2021-02-05 11:41

    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.

    0 讨论(0)
提交回复
热议问题