有一个用ES6编写的Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
React库,它将被其他模块使用。库的入口指向由webpack创建的已编译,最小化,捆绑的文件。尝试从另一个模块导入该库时收到以下错误:
node: v9.0.0
npm: 5.5.1
"babel-loader": "~8.0.5"
"@babel/cli": "~7.2.3"
"@babel/core": "~7.4.3"
"webpack": "~4.16.5"
"webpack-cli": "~3.1.0"
"webpack-merge": "~4.1.4
版本:
index.js
我的common-components
库的根目录中有以下export { Dropdown, Icon, LoadingSpinner, Toggle } from './Components/index.js';
export { Localizer, LocalizedString } from './Utilities/index.js';
:
webpack.config.js
index.js
使用reactDist/js/main.js
作为进入库的主要入口点,并将其输出到reactDist/
js/
css/
img/
map/
文件。
这是目录的以下结构,其中包含从Webpack进行转译,压缩和捆绑的文件:
js
vendor.js
目录包含一个vendors.js
,runtime.js
和package.json
。
main
reactDist/js/main.js
字段指向common-components
以下是当前从import { LoadingSpinner } from 'common-components';
库中导入组件的方式:
{{1}}
我希望上面的组件能够成功导入,但是看来这与前面提到的堆栈跟踪不一样。