[。babelrc语法加倍,同时尝试使用babel-plugin-proposal-class-properties

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

全部,

我正在尝试将babel-plugin-proposal-class-properties包含在我的代码包中,但出现以下错误;

2020-01-07 08:19:31.593 [错误] [tid:NSOperationQueue 0x2817acc40(QOS:已查看)] [RCTCxxBridge.mm:414]无法加载错误为([index。 js:无法从“ / Users / bburch / Projects / systems / SystemsDockConfig”找到模块“ babel-plugin-plugin-proposal-class-properties”-您的意思是“ @ babel / plugin-proposal-class-properties”吗? (空))

我的.babelrc看起来像;

http://169.254.99.36:8081/index.bundle?platform=ios&dev=true&minify=false

我也尝试过这种语法;

{   "presets": [
    "@babel/env",
    "@babel/react",   ],   "plugins": ["proposal-class-properties",] }

在任何一种情况下,软件包名称的“插件”部分都会被加倍,并且在发生这种情况时当然找不到该模块。

我的package.json;

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ],
  "plugins": ["@babel/plugin-proposal-class-properties"]
}
ios reactjs syntax babel
1个回答
0
投票

我建议您将.babelrc更改为babel.config.json并使用{确保您安装npm我--save-dev @ babel / plugin-proposal-class-properties这应该工作bable.config.json

{
  "name": "SystemsDockConfig",
  "version": "0.0.2",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@babel/plugin-proposal-class-properties": "^7.7.4",
    "@babel/plugin-syntax-object-rest-spread": "^7.7.4",
    "@babel/preset-env": "^7.7.7",
    "buffer": "^5.0.7",
    "eslint": "^6.8.0",
    "eventemitter3": "^4.0.0",
    "native-base": "^2.13.8",
    "react": "16.8.3",
    "react-native": "0.59.10",
    "react-native-ble-plx": "1.1.0",
    "react-native-camera": "^1.0.0",
    "react-native-router-flux": "^4.0.6",
    "react-native-version-number": "^0.3.1",
    "react-native-wheel-datepicker": "^2.1.8"
  },
  "devDependencies": {
    "@babel/core": "^7.6.4",
    "@babel/runtime": "^7.6.3",
    "babel-jest": "^24.9.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native"
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.