相关文章推荐
酷酷的橙子  ·  SetWindowsHookExW 函数 ...·  3 周前    · 
冷静的树叶  ·  流粼 - 知乎·  1 年前    · 
仗义的山羊  ·  SQL ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm brand new to react-native, and trying to render my first bit of text on the screen.

When I run react-native run-ios and then click into my sample app, I see the following error:

TransformError ENOENT: no such file or directory, open '.../albums/node_modules/babel-preset-react-native/index.js' while processing preset '.../babel-preset-react-native/index.js' RCTFatal RCTCxxBridge handleError

index.js DOES exist in my project, with the following code:

'use strict';
module.exports = require('./configs/main');

So far, I have tried the following:

1) Re-installing npm for babel-preset-react-native

2) Using yarn to remove and then re-add babel-preset-react-native
yarn remove babel-preset-react-native
yarn add babel-preset-react-native@2.1.0

3) Deleting babel.rc entirely

Nothing has worked. Eager to hear advice and suggestions for other things to try.

This is bug in the new version of babel-preset-react-native as it will added automatically after you run react-native init command

Please take a look at this github issue https://github.com/facebook/react-native/issues/15513

Workaround, try to change the version:

yarn remove babel-preset-react-native
yarn add babel-preset-react-native@2.1.0

if that's not work for you, try to remove trailing comma at node_modules/babel-preset-react-native/configs/main.js at this code below

https://github.com/facebook/react-native/blob/6ad7e8281b37ee2ce6425363c0b17420d056807a/babel-preset/configs/main.js#L40 and re-run your app

Thank you! This worked. I had tried these remove and add commands before, but I hadn't closed the React Packager terminal after running them. After closing the terminal and running the commands, I was back in business. – gfahs Aug 18, 2017 at 17:45

I got same problem yesterday and my way is:
1. Go to node_modules and remove babel-preset-react-native folder.
2. In root project type: npm install babel-preset-react-native@2.1.0 --save-dev

Hope you get this solved.

Thanks for responding! The other suggestions worked - but I'm totally keeping this in my back pocket, in case I encounter the issue again. – gfahs Aug 18, 2017 at 17:47
  • Go to node_modules and remove babel-preset-react-native folder.
  • In root project type:
    npm install babel-preset-react-native@2.1.0 --save-dev
  • Hope you get this solved.

    Thanks GaBACK

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.