ESlint - import.meta causes Fatal Parsing Error

前端 未结 1 898
情话喂你
情话喂你 2020-12-19 22:11

Using the Atom editor, with the linter-eslint package installed, I have a node.mjs script that uses ES6 module\'s import statement to import various node modules.

Th

相关标签:
1条回答
  • 2020-12-19 22:40

    I am sure the is not the best solution but I did this...

    First create another file (I used Util.mjs) and move the logic into that...

    import path from 'path';
    const __dirname = path.dirname(new URL(import.meta.url).pathname);
    export { __dirname }
    

    Then create .eslintignore and add {path}/Util.mjs. Finally use the new import in your original class...

    import {__dirname} from './Util.mjs';
    
    0 讨论(0)
提交回复
热议问题