aWebDeveloper
aWebDeveloper

Reputation: 38332

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"

Upvotes: 4

Views: 6503

Answers (1)

Anshul Jain
Anshul Jain

Reputation: 785

No need to write module.exports. You can write

export { Button };

Upvotes: 7

Related Questions