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.

JS: `import` does not work

See original GitHub issue

Describe the bug

One would expect import to work, as it is just default js by now.

It shows “Error: Cannot use import statement outside a module” … but the root of a JS env should be module compatible.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

1.0.317502+9c2a225c543085a04516cc4fc490919d5925ba87

  • OS
    • Windows 11
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Firefox
    • Safari
  • Frontend
    • Jupyter Notebook
    • Jupyter Lab
    • nteract
    • Visual Studio Code
    • Visual Studio Code Insiders
    • Visual Studio
    • Other (please specify)

Screenshots

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
brettfocommented, Jan 5, 2023

There’s a slightly odd workaround that we found; it requires using an HTML cell for the import line (and assigning it to the window object) and in a separate JS cell running the actual code.

image
0reactions
colombodcommented, Jan 10, 2023

interesting use of import here

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - ES6 imports doesn't work
1. You need to include type="module" in your script tag. · the issue is likely that for ES6 modules to work in javascript,...
Read more >
Why import in js not working?
js only sets a variable and exports, but doesn't do anything else. data.js has the console.log , so you should find out how...
Read more >
Javascript Fix Cannot Use Import Statement Outside A ...
Learn how to fix cannot use import statement outside a module error and successfully import function from another file in JavaScript.
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 >
import() - JavaScript - MDN Web Docs - Mozilla
The import() call is a syntax that closely resembles a function call, but import itself is a keyword, not a function. You cannot...
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