简体   繁体   English

React Native 无法解析 babel 插件

[英]React Native cannot resolve babel plugin

Error Message错误信息

Unknown plugin \\"require-all\\" specified in "\\project\\directory\\path\\.babelrc.env.development" “\\project\\directory\\path\\.babelrc.env.development”中指定的未知插件\\“require-all\\”

My files我的文件

.babelrc .babelrc

{
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source", "require-all"]

    }
   }
}

package.json包.json

{
  "name": "text-adventure-app",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-plugin-require-all": "0.0.1",
    "jest-expo": "~27.0.0",
    "react-native-scripts": "1.14.0",
    "react-test-renderer": "16.3.1"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "clear": "^0.1.0",
    "create-react-class": "^15.6.3",
    "expo": "^27.0.1",
    "react": "16.3.1",
    "react-native": "~0.55.2",
    "react-native-typewriter": "^0.5.3"
  }
}

babel-plugin-require-all babel-plugin-require-all

installed via npm as described here: https://github.com/dushaobindoudou/babel-plugin-require-all通过 npm 安装,如下所述: https : //github.com/dushaobindoudou/babel-plugin-require-all

What I've tried我试过的

  • Changing "require-all" to "babel-plugin-require-all"将“require-all”更改为“babel-plugin-require-all”
  • Deleting and re-installing my node_modules删除并重新安装我的 node_modules
  • Clearing npm cache清除 npm 缓存
  • Scoured the internet for advice on including babel plugins在互联网上搜索有关包含 babel 插件的建议

There is a problem in the package.json for that plugin - there is an extra该插件的package.json存在问题 - 有一个额外的(space) in the main property which means babel can't resolve it. (space) 在main属性中,这意味着 babel 无法解析它。 I verified this by removing the space from the end of the line, and it successfully compiles.我通过从行尾删除空格来验证这一点,并且它成功编译。

My advice in this case would be to use a different package (maybe something like https://github.com/vihanb/babel-plugin-wildcard could help) or submit a pull request to the babel-plugin-require-all package to remove the extra space.在这种情况下,我的建议是使用不同的包(也许像https://github.com/vihanb/babel-plugin-wildcard 之类的东西可能会有所帮助)或向babel-plugin-require-all包提交拉取请求以删除多余的空间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native Typescript babel-plugin-module-resolver 错误:找不到模块或其对应的类型声明 - React Native Typescript babel-plugin-module-resolver error: Cannot find module or its corresponding type declerations React Native-未定义的babel-plugin-module-resolver'1' - React native - babel-plugin-module-resolver '1' of undefined BABEL 找不到模块“节点:路径”错误 react-native - BABEL Cannot find module 'node:path' error react-native React-Native:无法将babel更新为ES7 - React-Native: Cannot update babel to ES7 运行 React App 时找不到模块“@babel/plugin-transform-react-jsx-source” - Cannot find module '@babel/plugin-transform-react-jsx-source' when running React App React Native-运行assmbleResase时出现意外的令牌静态propTypes,babel插件不起作用 - React Native - unexpected token static propTypes when running assmbleRelease, babel plugin doesnt work yahoo / babel-plugin-react-intl评估.native.js文件扩展名 - yahoo/babel-plugin-react-intl evaluates .native.js file extensions React Native 报错:导出命名空间应该先由`@babel/plugin-proposal-export-namespace-from 转换 - React Native error: Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from 错误:无法解析模块“babel-loader” - Error: Cannot resolve module 'babel-loader' 尝试在 React Native 中组织模块时无法解析模块 - Cannot resolve module while trying to organize modules in React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM