admin管理员组

文章数量:1327849

This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'

I am getting the above error while trying to move the entire application from react v15.6to v16.2, by using the migration tool from facebook like jscodeshift.

This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'

I am getting the above error while trying to move the entire application from react v15.6to v16.2, by using the migration tool from facebook like jscodeshift.

Share asked Aug 17, 2018 at 4:44 Praveen KumarPraveen Kumar 2,0242 gold badges10 silver badges16 bronze badges 3
  • It is a known issue github./facebook/jscodeshift/issues/252 – Dipen Shah Commented Aug 17, 2018 at 4:46
  • 3 amazing what you can find by simply using a search engine on the exact title of the question! – Jaromanda X Commented Aug 17, 2018 at 5:01
  • Possible duplicate of Babel's TypeScript parsing is not consistent – Praveen Kumar Commented Aug 20, 2018 at 15:30
Add a ment  | 

2 Answers 2

Reset to default 2

Add @babel/plugin-proposal-export-default-from (https://git.io/vb4yH) to the 'plugins' section of your Babel config to enable transformation.

I solved this problem.

const parser = require('./src/parser');
const jscodeshift = require('jscodeshift').withParser(parser);

./src/parser:

'use strict';

const babylon = require('babylon');

// These are the options that were the default of the Babel5 parse function
// see https://github./babel/babel/blob/5.x/packages/babel/src/api/node.js#L81

const options = {
  sourceType: 'module',
  allowHashBang: true,
  ecmaVersion: Infinity,
  allowImportExportEverywhere: true,
  allowReturnOutsideFunction: true,
  plugins: [
    'estree',
    'jsx',
    'asyncGenerators',
    'classProperties',
    'doExpressions',
    'exportExtensions',
    'functionBind',
    'functionSent',
    'objectRestSpread',
    'dynamicImport',
    'nullishCoalescingOperator',
    'optionalChaining',
    'exportDefaultFrom'
  ],
};

/**
 * Wrapper to set default options
 */
exports.parse = function parse (code) {
  return babylon.parse(code, options);
};

Please add the 'exportDefaultFrom' into plugins.

本文标签: javascriptThis experimental syntax requires enabling the parser plugin 39exportDefaultFrom39Stack Overflow