[英]module.exports Cannot set property of undefined
I am trying to move all react components to separate repo so that they can be shared. 我正在尝试将所有React组件移到单独的仓库中,以便可以共享它们。 I am getting the above error
我收到上述错误
ui-react/index.js ui-react / index.js
'use strict';
import Button from "./components/Button/Button";
module.exports.Button = Button;
FileB 文件B
import {Button} from 'ui-react';
When i do this i get an error called. 当我这样做时,我得到一个错误。
'ui-react' does not contain an export named 'Button'
PS: In package.json of ui-react i have set main to index.js and i have also tried import "ui-react/index" PS:在ui-react的package.json中,我将main设置为index.js,并且我还尝试了导入“ ui-react / index”
No need to write module.exports. 无需编写module.exports。 You can write
你可以写
export { Button };
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.