运行react-native init 新建0.57.1项目运行报错 【`@babel/runtime/helpers/interopRequireDefault` does not exist】

2018-09-29 16:02:11.285108+0800 MyProject[42509:331244] Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `/Users/hjs/Desktop/worksplace/MyProject/index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968

To resolve try the following:

  1. Clear watchman watches: `watchman watch-del-all`.

  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.

  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.

  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`. (null))

解决方法:

1. 项目根目录下运行:

npm add @babel/runtime

2. 重新install依赖

npm install

重新运行即可。

发布了36 篇原创文章 · 获赞 64 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/u010379595/article/details/82899181