将 ES6 "import" 转换为 nodejs "require" 的正确方法

Correct way to translate ES6 "import" to nodejs "require"

我正在尝试在我的项目中重现 here 报告的示例。 问题是我使用的 Browseryfy 似乎不支持 ES6 导入。 所以我想到了翻译示例的第三个导入 from:

import {Treebeard} from 'react-treebeard';

var Treebeard = require('react-treebeard').default;

但还是不行,我收到以下错误:

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

我读到试图切换到 babelify,但我会把这个选项视为最后一个选项。 谢谢!

var Treebeard = require('react-treebeard').Treebeard;