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.

Uncaught SyntaxError: Invalid or unexpected token using forceAllTransforms preset

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current behavior

  • Manually transpiling using babel.transform() with forceAllTransforms preset
  • After viewing the result, I got the “Uncaught SyntaxError: Invalid or unexpected token” error in console

Input Code

babel.transform(code, {
                comments: false,
                compact: true,
                minified: true,
                presets: [
                    [
                        "@babel/preset-env",
                        {
                            targets: {
                                chrome: 59,
                                edge: 13,
                                firefox: 50,
                            },
                            // for uglifyjs...
                            forceAllTransforms: true,
                        },
                    ],
                ],
            }, (err, result) => {
                ...
            });

Environment

  • Babel version(s): 7.12.3
  • Node/npm version: Node 14.15.3 / npm 6.14.4
  • OS: Windows 10
  • Monorepo: yes
  • How you are using Babel: webpack

Possible Solution

Removing the “\n” characters from generated line below, solves the issue

throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Mogget24commented, Jan 28, 2021

Can you share a repo which reproduces the issue?

I’m trying to create a clean repo in order to make it easy to find the issue as the problem has been found on a big (an private) repo I cannot share

0reactions
liuxingbaoyucommented, Sep 4, 2022

Since this issue has been inactive for a long time, I will close it for now, feel free to reopen it if the issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Invalid or unexpected token
I am a beginner so I get stuck in syntax a lot. If it is that then please help me out. javascript ·...
Read more >
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 >
Uncaught Syntaxerror: Invalid Or Unexpected Token For New ...
The JavaScript exception illegal character occurs when there is an invalid or unexpected token that doesn't belong at this position in the code....
Read more >
SyntaxError: Unexpected token in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: Having a <script /> tag that points to an HTML file instead of a...
Read more >
Uncaught SyntaxError: Invalid or unexpected token
You should try to exclude the file from being minified in Performance>Minify>Css>Never minify following css files save all settings and purge the case,...
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