-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: 'import' and 'export' may appear only with 'sourceType: "module"' #849
Comments
The default |
Hey @boopathi I don't believe that fixes it. The error says: Consider renaming the file to '.mjs', or setting sourceType:module or sourceType:unambiguous in your Babel config for this file. The file does have the |
@boopathi I'm running into the same issue. My file extension is |
My workaround was to directly use const minifyPreset = require('babel-preset-minify');
const babel = require('@babel/core');
const fs = require('fs');
const args = process.argv.slice(2);
if (args.length !== 2) {
throw new Error('Must pass two arguments, input and output filename');
}
const { code } = babel.transformSync(fs.readFileSync(args[0]), {
minified: true,
sourceType: "module",
configFile: false,
presets: [[minifyPreset]]
});
fs.writeFileSync(args[1], code); |
I'm still getting the same issue |
Same problem...uninstalling... |
Same here still. The file does have the .mjs extension. Sad. |
Ran into this error, then renamed file to ".mjs", but still got this error:
Environment: Node.js v10.1
The text was updated successfully, but these errors were encountered: