Dale_Plante
Dale_Plante

Reputation: 934

React Native cannot resolve babel plugin

Error Message

Unknown plugin \"require-all\" specified in "\project\directory\path\.babelrc.env.development"

My files

.babelrc

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

    }
   }
}

package.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

installed via npm as described here: https://github.com/dushaobindoudou/babel-plugin-require-all

What I've tried

Upvotes: 1

Views: 1650

Answers (1)

David
David

Reputation: 1356

There is a problem in the package.json for that plugin - there is an extra (space) in the main property which means babel can't resolve it. 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.

Upvotes: 2

Related Questions