Skip to content

Error: 'import' and 'export' may appear only with 'sourceType: "module"' #849

@zhanzhenzhen

Description

@zhanzhenzhen

Ran into this error, then renamed file to ".mjs", but still got this error:

$ npx minify fff.mjs --mangle.topLevel --outFile fff.min.mjs
SyntaxError: unknown: 'import' and 'export' may appear only with 'sourceType: "module"' (1:0)
Consider renaming the file to '.mjs', or setting sourceType:module or sourceType:unambiguous in your Babel config for this file.

> 1 | export let aaa = function(){};
    | ^
  2 |

Environment: Node.js v10.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions