'import' and 'export' may only appear at the top level
See original GitHub issueModule parse failed: /path/to/project/node_modules/imports-loader/index.js?this=>window!/path/to/project/src/entry.js 'import' and 'export' may only appear at the top level (4:0)
You may need an appropriate loader to handle this file type.
| (function() {
|
| import './NameSpace';
| import './Polyfill';
rules: [
{
test: regx,
use: [
{
loader: "imports-loader?this=>window",
},
],
},
],
But import 'imports-loader?this=>window./NameSpace';
this works fine.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:9 (2 by maintainers)
Top Results From Across the Web
'import' and 'export' may only appear at the top level
I'm using webpack with vuejs. Webpack does its thing, but when I look at the outputted app.js file, it gives me this error....
Read more >'import' and 'export' may only appear at the top level · Issue #304
Error: 'import' and 'export' may only appear at the top level abc: ../../node_modules/lodash-es/isBuffer.js (1:0) abc: 1: import root from ' ...
Read more >'import' and 'export' may only appear at the top level | bobbyhadz
The error "import and export may only appear at the top level" occurs when we forget a closing brace when declaring a function...
Read more >Import and export may only appear at the top level
The error "import and export may only appear at the top level" may occur due to a missing closing brace when declaring a...
Read more >How to fix: import and export may only appear at the top level
So I've setup a new Svelte project and install all the latest node modules. ... If you're developing a Svelte project, you're probably...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I’m a webpack beginner. I followed the webpack official guide using imports-loader and found an error
@SteinNs I had the same issue then I found that
imports-loader
just does this to my module:If there is an
import
statement in the module, webpack will throw an error to the terminal because the statement is in a function, not at the top level. You can use CommonJSrequire
function instead.