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.

Error if there is an "Import" statement at the beginning of js file

See original GitHub issue

I am receiving an error if the js file consists of import statement. For example, here is the content of the test.js file:

import { test1} from "./test1";

window.onload = () => {
console.log("Test");
};

command executed: javascript-obfuscator test.js --compact true

Here is the error received:

Error: Line 1: Unexpected token at Function.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:270611) at Function.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:270464) at e.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:266641) at e.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:266398) at Function.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:28815) at Function.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:44810) at e.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:44551) at e.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:11351) at e.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:44257) at e.value (C:\Users\pavma\AppData\Roaming\npm\node_modules\javascript-obfuscator\dist\index.js:24:11351)

javascript-obfuscator -v 0.14.3 node -v v8.9.4 npm -v 5.6.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sanex3339commented, Mar 1, 2018

Related to esprima. Obfuscator using parseScript method, but your code is module.

So i’ll wrap it in try-catch. If it will fail on parseScript- obfuscator will run parseModule

0reactions
sanex3339commented, Mar 30, 2018

javascript-obfuscator@0.15.0 just published to the npm!

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS Fix For "SyntaxError: Cannot Use Import Statement Outside ...
This is most likely triggered when a file tries to use both import and require module patterns, which isn't possible. You'll need to...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
"Uncaught SyntaxError: Cannot use import statement outside ...
There are three ways to solve this:- · 1. The first: In the script, include type=module · 2. The second: In node.js, into...
Read more >
Cannot use import statement outside a module [React ...
This error mainly occurs when you use the import keyword to import a module in Node.js. Or when you omit the type="module" attribute...
Read more >
Javascript Fix Cannot Use Import Statement Outside A Module
When you try to import a function that is declared in another js file, you'll probably get the error cannot use import statement...
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