Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"

like image 695
aWebDeveloper Avatar asked Oct 27 '25 03:10

aWebDeveloper


1 Answers

No need to write module.exports. You can write

export { Button };
like image 110
Anshul Jain Avatar answered Oct 28 '25 17:10

Anshul Jain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!