在部署到Heroku期间获取扩展操作符语法错误

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

将我的应用程序部署到Heroku时出现以下错误:

remote: SyntaxError: src/resolvers/Mutation.js: Unexpected token (21:16)
remote:   19 |         const user = await prisma.mutation.createUser({
remote:   20 |             data: {
remote: > 21 |                 ...data,
remote:      |                 ^
remote:   22 |                 password,
remote:   23 |                 permissions,
remote:   24 |                 authentication

在Heroku的后期构建阶段,其余的扩展未被识别。

我目前在index.js中具有以下内容:

import '@babel/polyfill'

我的package.json

  "dependencies": {
    "@babel/polyfill": "^7.0.0",
    "babel-cli": "^6.26.0",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-register": "^6.26.0",
    "bcryptjs": "^2.4.3",
    "cross-fetch": "^2.2.2",
    "env-cmd": "^8.0.2",
    "google-auth-library": "^4.2.3",
    "graphql": "^0.13.2",
    "graphql-cli": "^2.16.4",
    "graphql-yoga": "^1.14.10",
    "jsonwebtoken": "^8.3.0",
    "nodemailer": "^6.2.1",
    "prisma-binding": "^2.1.1",
    "stripe": "^7.1.0"
  },
  "devDependencies": {
    "babel-plugin-transform-es2015-destructuring": "^6.23.0",
    "jest": "^23.5.0",
    "nodemon": "^1.17.5"
  }

我尝试过_babelrc

{
    "presets": [
        "env"
    ],
    "plugins": [
        "transform-object-rest-spread"
    ]
}

{
    "presets": [
        "react",
        "es2015",
        "stage-3",
        "env"
    ],
    "plugins": [
        ["@babel/plugin-proposal-object-rest-spread", { "loose": true, "useBuiltIns": true }],
        "transform-es2015-destructuring"
    ]
}

{
  "presets": [
    "env",
    "stage-0",
    "react"
  ]
}

{
  "presets": ["react", "es2015"],
  "plugins": ["transform-es2015-destructuring", "transform-object-rest-spread"]
}

但是无效。不知道如何解决此问题。...................

javascript node.js ecmascript-6 babeljs babel
1个回答
1
投票

[_babelrc不是babel的公认配置格式文件-要配置babel,您需要使用其config files documentation中列出的方法之一:

  • .babelrc
  • .babelrc.js
  • .babelrc.cjs
  • package.json
© www.soinside.com 2019 - 2024. All rights reserved.