语法错误:@rnmapbox/maps 模块的 Mapbox.ts 中存在意外标记,预期为“,”

问题描述 投票:0回答:1

我在 React Native 项目中遇到了 @rnmapbox/maps 模块的问题。当我尝试捆绑index.js文件时,遇到以下错误:


SyntaxError: C:\WORK\plotlot\plotlot-25398\android\node_modules\@rnmapbox\maps\src\Mapbox.ts: Unexpected token, expected "," (5:7)

  3 |   Camera,
  4 |   UserTrackingMode,
> 5 |   type CameraPadding,
    |        ^
  6 |   type CameraAnimationMode,
  7 |   type CameraBounds,
  8 | } from './components/Camera';

错误似乎指向 @rnmapbox/maps 模块中的 Mapbox.ts 文件。具体来说,它与相机模块的导入语句有关。第 5 行是问题发生的地方,解析器期望在输入 CameraPadding 之后有一个逗号,但似乎是某些意外情况导致了问题。

这是我正在尝试运行的代码


import React from 'react';
import { StyleSheet, View ,Text} from 'react-native';
import Mapbox from '@rnmapbox/maps';

Mapbox.setAccessToken('access_token');

const HomeScreen = () => {
    return (
        <View style={styles.page}>
            <View style={styles.container}>
                <Text>test</Text>
                <Mapbox.MapView style={styles.map} />
            </View>
        </View>
    );
}

export default HomeScreen;

const styles = StyleSheet.create({
    page: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    container: {
        height: 300,
        width: 300,
    },
    map: {
        flex: 1
    }
});

依赖项

“反应”:“17.0.2”, “反应本机”:“0.66.5”, “@rnmapbox/maps”:“10.0.4”,

android node.js reactjs react-native mapbox
1个回答
0
投票

我也遇到同样的错误,请问如何解决?

© www.soinside.com 2019 - 2024. All rights reserved.