简体   繁体   中英

module.exports Cannot set property of undefined

I am trying to move all react components to separate repo so that they can be shared. I am getting the above error

ui-react/index.js

'use strict';

import Button from "./components/Button/Button";

module.exports.Button = Button;

FileB

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"

No need to write module.exports. You can write

export { Button };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM