'import' and 'export' may only appear at the top level

后端 未结 15 1585
耶瑟儿~
耶瑟儿~ 2020-12-08 18:00

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.

\'import\' and \'export\

15条回答
  •  醉酒成梦
    2020-12-08 18:57

    I had the same issue using webpack4, i was missing the file .babelrc in the root folder:

    {
        "presets":["env", "react"],
        "plugins": [
            "syntax-dynamic-import"
        ]
    }
    

    From package.json :

    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    

提交回复
热议问题