首页 > 解决方案 > React Native Web - 当前未启用对实验性语法“jsx”的支持

问题描述

我已经尝试了以前的答案中提到的但无法解决错误:

SyntaxError:node_modules\react-native-gifted-chat\lib\GiftedChat.js:当前未启用对实验性语法“jsx”的支持 (337:27):

babel.config.js:

module.exports = function (api) {
  const presets = ["@babel/preset-env", "@babel/preset-react"];
  const plugins = ["@babel/plugin-transform-runtime"];

  /** this is just for minimal working purposes,
   * for testing larger applications it is
   * advisable to cache the transpiled modules in
   * node_modules/.bin/.cache/@babel/register* */
  api.cache(false);

  return {
    presets,
    plugins,
  };
};

包.json

 "devDependencies": {
    "@babel/plugin-syntax-jsx": "^7.14.5",
    "@babel/plugin-transform-runtime": "^7.9.0",
    "@babel/preset-env": "^7.15.0",
    "@babel/preset-react": "^7.14.5"
  }

我完全不知道这里出了什么问题。预设已安装,插件已安装但没有任何效果,我得到同样的错误。

标签: javascriptnode.jsreactjsreact-nativebabeljs

解决方案


推荐阅读