question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"SyntaxError: Unexpected token *" issue

See original GitHub issue

hi @wellyshen @Rid, Do you guys have experience with below issue, I got stuck with it for a day, and still don’t know how to fix. Please help me 😃.

I think it does not understand ES6 syntax on server side

Before add babel-loader config to config.babel.js, I got below error image

After add this configuration to config.babel.js, I solved this error image

but still remain below error: image

Error details:

/working/source/examples/react-cool-starter/node_modules/@ansarada/ace-react/dist/ace/components/index.js:4 import * as editor from ‘./Editor’; ^

SyntaxError: Unexpected token * at Module._compile (internal/modules/cjs/loader.js:723:23) at Module._compile (/working/source/examples/react-cool-starter/node_modules/pirates/lib/index.js:99:24) at Module._extensions…js (internal/modules/cjs/loader.js:789:10) at Object.newLoader [as .js] (/working/source/examples/react-cool-starter/node_modules/pirates/lib/index.js:104:7) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/working/source/examples/react-cool-starter/src/pages/Home/Home.js:6:1) at Module._compile (internal/modules/cjs/loader.js:778:30) at Module._compile (/working/source/examples/react-cool-starter/node_modules/pirates/lib/index.js:99:24) at Module._extensions…js (internal/modules/cjs/loader.js:789:10) at Object.newLoader [as .js] (/working/source/examples/react-cool-starter/node_modules/pirates/lib/index.js:104:7) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at Object.requireSync (/working/source/examples/react-cool-starter/src/pages/Home/index.js:6:14) at InnerLoadable.loadSync (/working/source/examples/react-cool-starter/node_modules/@loadable/component/dist/loadable.cjs.js:188:35) at new InnerLoadable (/working/source/examples/react-cool-starter/node_modules/@loadable/component/dist/loadable.cjs.js:128:17) at processChild (/working/source/examples/react-cool-starter/node_modules/react-dom/cjs/react-dom-server.node.development.js:2846:14) ==> 😭 Rendering routes error: SyntaxError: Unexpected token * GET / 404 14429.555 ms - 12

Content of the component which cause issue image

The line which cause issue image

Thank you so much.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Ridcommented, Aug 28, 2019

Please confirm that your package.json contains:

"babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "useBuiltIns": "usage",
          "corejs": "3.0.0"
        }
      ],
      "@babel/preset-react",
      "@babel/preset-flow"
    ],
    "plugins": [
      "react-hot-loader/babel",
      "@loadable/babel-plugin",
      "@babel/plugin-proposal-class-properties",
      "@babel/plugin-syntax-dynamic-import"
    ],
    "env": {
      "production": {
        "plugins": [
          "transform-remove-console",
          "transform-react-remove-prop-types"
        ]
      }
    }
  },

Do you have a link to the repository you’re working from?

1reaction
Ridcommented, Aug 28, 2019

@hienhuynhtm can you let us know the command you’re running when you get this error?

i.e. yarn dev or yarn build && yarn start

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
SyntaxError: Unexpected token in JavaScript | bobbyhadz
The error message means that one character was expected, but another character was provided. This is commonly due to typos.
Read more >
syntax error: unexpected token - javascript - Stack Overflow
The error SyntaxError: Unexpected token < likely means the API endpoint didn't return JSON in its document body, such as due to a...
Read more >
Have a JavaScript Unexpected Token Error? Check Your Syntax
Today, we are discussing the Unexpected Token Error within our JavaScript Error Handling series. This JavaScript error is a subset of the ...
Read more >
SyntaxError: Unexpected token in JavaScript - Stack Diary
The "SyntaxError: Unexpected token" error in JavaScript is a common syntax error that occurs when the JavaScript interpreter encounters a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found