Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token ... ( spread operator ) #9675

Open
OAmor opened this Issue Mar 13, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@OAmor
Copy link

OAmor commented Mar 13, 2019

Bug Report

Babel can't recognize spread operator (..)

return resolve(user && { ...user, domain });

i tried many solutions but without result,
.babelrc

{
  "presets": ["env",
    "stage-0",
    "react"],
  "plugins": [["styled-components", { "ssr": true, "displayName": true, "preprocess": false }]]
}

and this is my package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "test",
  "main": "./server/server.js",
  "scripts": {
    "test": "mocha --require babel-core/register ./client/**/__test__/*.js",
    "dev": "node ./server/server.js",
    "build": "next build ./client",
    "start": "NODE_ENV=production node ./server/server.js",
    "prod": "npm run build && npm run start",
    "lint": "./node_modules/.bin/eslint . --fix",
    "lint:nofix": "./node_modules/.bin/eslint ."
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint:nofix"
    }
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/shakesBeardZ/xamber.git"
  },
  "keywords": [
    "url-shortener"
  ],
  "author": "Pouria Ezzati <ezzati.upt@gmail.com>",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/shakesBeardZ/xamber.git"
  },
  "homepage": "https://xamber.sa",
  "dependencies": {
    "@babel/preset-react": "^7.0.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.5",
    "@fortawesome/free-brands-svg-icons": "^5.4.1",
    "@fortawesome/free-solid-svg-icons": "^5.4.0",
    "@fortawesome/react-fontawesome": "^0.1.3",
    "@sendgrid/mail": "^6.3.1",
    "axios": "^0.18.0",
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.18.2",
    "compression": "^1.7.3",
    "cookie-parser": "^1.4.3",
    "cors": "^2.8.4",
    "date-fns": "^1.29.0",
    "email-validator": "^2.0.4",
    "express": "4.16.4",
    "express-validator": "^5.3.0",
    "file-saver": "^2.0.0-rc.4",
    "geoip-lite": "^1.2.1",
    "helmet": "^3.14.0",
    "js-cookie": "^2.2.0",
    "jsonwebtoken": "^8.1.0",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.4",
    "mailchimp-api-v3": "^1.12.0",
    "morgan": "^1.9.0",
    "nanoid": "^1.0.1",
    "neo4j-driver": "^1.5.2",
    "next": "7.0.2",
    "next-ga": "^2.3.1",
    "next-redux-wrapper": "^2.0.0",
    "nodemailer": "^4.4.1",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "passport-localapikey-update": "^0.6.0",
    "prop-types": "^15.6.0",
    "qrcode.react": "^0.8.0",
    "raven": "^2.4.0",
    "react": "16.6.0",
    "react-copy-to-clipboard": "^5.0.1",
    "react-dom": "16.6.0",
    "react-inlinesvg": "^0.8.2",
    "react-intercom": "^1.0.14",
    "react-redux": "^5.0.6",
    "recharts": "^1.0.0-beta.10",
    "redux": "^4.0.1",
    "redux-devtools-extension": "^2.13.2",
    "redux-thunk": "^2.2.0",
    "styled-components": "^4.0.2",
    "url-regex": "^4.1.1",
    "useragent": "^2.2.1",
    "valid-url": "^1.0.9",
    "sshpk": "^1.13.1",
    "stringstream": "^0.0.5",
    "just-extend": "3.0.0",
    "cryptiles": "^3.1.2",
    "base64url": "^2.0.0"
  },
  "devDependencies": {
    "babel": "^6.23.0",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.1",
    "babel-plugin-styled-components": "^1.3.0",
    "babel-plugin-transform-es2015-spread": "^6.22.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-0": "^6.24.1",
    "chai": "^4.1.2",
    "deep-freeze": "^0.0.1",
    "eslint": "^5.7.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-prettier": "^3.0.0",
    "eslint-plugin-react": "^7.5.1",
    "husky": "^1.1.2",
    "mocha": "^5.2.0",
    "nock": "^10.0.1",
    "prettier": "^1.10.2",
    "redux-mock-store": "^1.5.3",
    "sinon": "^7.1.0"
  }
}

Environment

  • Babel version(s): [6.23.0]
  • Node/npm version: [8.0.0/6.9.0]
  • OS: [ubuntu 16.04]

this is a screenshot for the error message
https://s1.gulfupload.com/i/00085/f1rwp8ymvwy6.png

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Mar 13, 2019

Hey @OAmor! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@danez

This comment has been minimized.

Copy link
Member

danez commented Mar 17, 2019

You are mixing different versions of babel as you have @babel/preset-react installed, which is babel v7, all the other dependencies are babel v6.

Ensure you either only use babel v6 or only the latest version which is v7.

npm uninstall @babel/preset-react
npm install --dev babel-preset-react

This should make it work with babel 6. The stage-0 preset should come with support for object-spread.

@danez danez added i: 6.0 and removed i: bug i: needs triage labels Mar 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.