构建react原生iOS时,出现意外的令牌名称«_000»,预期为双关语«,»

wsewodh2  于 2023-04-07  发布在  React
关注(0)|答案(2)|浏览(114)

我得到一个Unexpected token name «_000», expected punc «,»,但我的文件看起来有效?任何想法这可能是什么

app/services/API/api.ts

import { ApisauceInstance, create } from "apisauce"

// Use this import if you want to use "env.js" file
// const { API_URL } = require("../../config/env")
// Or just specify it directly like this:
const API_URL = "http://localhost:3000/app" // update later

export class Api {
  apisauce: ApisauceInstance

  setup() {
    this.apisauce = create({
      baseURL: API_URL,
      timeout: 10_000,
      headers: {
        Accept: "application/vnd.api+json",
        "Content-Type": "application/vnd.api+json",
      },
    })
  }
}
error app/services/api/api.ts: Unexpected token name «_000», expected punc «,» in file app/services/api/api.ts at 27:21.
Error: Unexpected token name «_000», expected punc «,» in file app/services/api/api.ts at 27:21
    at minifyCode (/Users/cvdv/ss/mobile/node_modules/metro-transform-worker/src/index.js:99:13)
    at transformJS (/Users/cvdv/ss/mobile/node_modules/metro-transform-worker/src/index.js:317:28)
    at transformJSWithBabel (/Users/cvdv/ss/mobile/node_modules/metro-transform-worker/src/index.js:408:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.transform (/Users/cvdv/ss/mobile/node_modules/metro-transform-worker/src/index.js:569:12)
kcwpcxri

kcwpcxri1#

timeout: 10_000,替换为timeout: 10000,

kiz8lqtg

kiz8lqtg2#

如果不想删除数字分隔符,请升级到metro-react-native-babel-preset@0.74.1,或单独安装@babel/plugin-proposal-numeric-separator并添加到.babelrcplugins

相关问题