7

When I'm trying to start a new react-native project from scratch I'm getting this message.

/Users/jorgevenegas/Dev/Projects/testreact/List/node_modules/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:327
          throw new Error("Couldn't find preset " + JSON.stringify(val) + " relative to directory " + JSON.stringify(dirname));
          ^

Error: Couldn't find preset "es2015" relative to directory "/Users/jorgevenegas/Dev/Projects"

I have installed react-native-cli, of course. Using node v4.2.1, react-native 0.1.5, watchman and flow installed too.

Seems to be something related to babel. I can't figure out the reason, though.

I'm attaching a screenshot with a more detailed output.

Error Output

Thanks in the advance!

Community
  • 1
  • 1
jorgevenegas
  • 101
  • 1
  • 5

5 Answers5

7

This bugged me for a good 1 day. The issue was I had a .babelrc file up in my file hierarchy which was interfering with babel parsing. Got rid of that and it was fine. react-native uses es2015 by default so .babelrc is not required.

Illuminati
  • 4,539
  • 2
  • 35
  • 55
6

Try installing the following packages

npm install babel-preset-es2015 --save
npm install babel-preset-react --save
ThorbenA
  • 1,863
  • 3
  • 16
  • 27
  • Thing is "react-native init" creates the whole project, so I can't install those packages when I'm running the init command. Anyway, I've tried by installing them globally but I got the same error message. – jorgevenegas Mar 05 '16 at 23:30
  • 1
    After those command you may need a npm install, that is how worked for me. – mejiamanuel57 Apr 11 '16 at 14:10
1

I had the same problem. The solution for me was to switch from 'workspace/MyProject' (for you its "/Users/jorgevenegas/Dev/Projects" i guess) to 'workspace'.

I don't know why I had to do this, but when i ran

npm install babel-preset-es2015
npm install babel-preset-react

in my workspace instead, i could cd into 'MyProject' again and execute a react-native run-android from there.

Hope that helps at least some people encountering the same problem.

LarsK
  • 11
  • 1
1

Add the following line to your .babelrc file:

{"presets": ["react"]}

I find solution from babel.io

Richard Xue
  • 307
  • 2
  • 5
0

I went through something similar, maybe this can help. In my case it was because for some reason I had two instances of react-native installed on my system.

Check the output of

which -a react-native

If you get more than one path with react native installed, get rid of the one that gives you the same error when executing init directly with the full path (my case was one installed at /usr/local/bin/react-native, but yours could be slightly different).

After removing the wrong one, you should be able to init projects without any problems.

  • I realized that I had two instances of Node installed on my laptop. I decided to uninstall everything and start from scratch with NVM. I'm still having the same issue. – jorgevenegas Mar 05 '16 at 23:32