React native 未能编译本机网站

React native 未能编译本机网站,react-native,React Native,我是一个初学者,不会做出土生土长的反应 我所做的: 1) 新项目博览会 2) 选定的空项目 3) 世博会开幕——网络 4) 选择在Android上运行 =========到目前为止,一切都在运行和编译================ 5) 选择在web浏览器上运行,然后获取此错误: WEB: Failed to compile D:/ReactNative/newProj/node_modules/@unimodules/react-native-adapter/build/errors/Cod

我是一个初学者,不会做出土生土长的反应

我所做的:

1) 新项目博览会

2) 选定的空项目

3) 世博会开幕——网络

4) 选择在Android上运行

=========到目前为止,一切都在运行和编译================

5) 选择在web浏览器上运行,然后获取此错误:

WEB: Failed to compile
D:/ReactNative/newProj/node_modules/@unimodules/react-native-adapter/build/errors/CodedError.js
ReferenceError: D:\ReactNative\newProj\node_modules\@unimodules\react-native-adapter\build\errors\CodedError.js: Unknown helper createSuper
这是我的App.js

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Hello World! </Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
这是我的basel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
  };
};
这是codererror.js

/**
 * A general error class that should be used for all errors in Expo modules.
 * Guarantees a `code` field that can be used to differentiate between different
 * types of errors without further subclassing Error.
 */
export class CodedError extends Error {
    constructor(code, message) {
        super(message);
        this.code = code;
    }
}
//# sourceMappingURL=CodedError.js.map

在我的项目中——根本不是react native——昨天也出现了同样的错误。这似乎与巴贝尔有关-loader@8.1.0这是最近发布的

在我的例子中,它帮助将其版本固定到8.0.6,即之前的版本

如果您使用的是纱线而不是npm,那么您现在应该能够通过向package.json添加一个resolutions字段来绕过它

首先,通过运行
why babel loader
,确保您的项目中有babel loader—它应该报告一些内容,而不是什么都没有。如果是这种情况,此解决方案应有助于:

在package.json中,添加:

"resolutions:" {
    "babel-loader": "8.0.6"
}
接下来,删除节点和纱线。锁定,然后再次运行纱线安装

"resolutions:" {
    "babel-loader": "8.0.6"
}