代码之家  ›  专栏  ›  技术社区  ›  AltBrian

运行react App时找不到模块'@babel/plugin transform react jsx source'

  •  5
  • AltBrian  · 技术社区  · 6 年前

    我刚刚用创建了一个React应用程序 create-react-app aquastars 然后使用 yarn run eject

    我什么都没做!我需要做些什么来启动和运行它?任何帮助都将不胜感激。

    4 回复  |  直到 5 年前
        1
  •  39
  •   Fernando Rojo    6 年前

    这个 solution by @xiaobo 对我来说是不够的。把expo升级到v32之后,我花了一段时间才弄明白这一点,所以下面是我所做的,以防其他人也有同样的问题。(回答来自 expo forums .)

    如果你有 .babelrc 文件,将其重新命名为 .babelrc-old

    添加一个名为 babel.config.js 到存储库的根目录 .

    module.exports = function(api) {
      api.cache(true);
      return {
        presets: ['babel-preset-expo'],
      };
    };
    

    准备就绪!

        2
  •  18
  •   Nick Schmidt    4 年前

    在你执行之后 npm run eject :

    1. cd /your/project/path (忽略)
    2. rm -rf node_modules
    3. npm install yarn install
    4. 运行之前失败的脚本(在您的情况下很可能是: yarn start npm start ).
        3
  •  4
  •   RKM    6 年前

    删除整个 node_modules yarn 让它工作。 rm -R node_modules/ rm yarn.lock yarn install

        4
  •  3
  •   Gildo Vargas    6 年前

    在我的例子中,通过在Reactjs上安装“@babel”, @babel/plugin-transform-react-jsx

    1: yarn add @babel/plugin-transform-react-jsx
    2: yarn start

        5
  •  1
  •   Risen human    6 年前

        6
  •  0
  •   ham118    5 年前

    刚刚结束后就消除了这个错误 文件 那是在 .