0

I've created a small react component, and uploaded it to a private npm. I try to implement it in my create-react app. When I use it localy (npm link), all works preferct But when I try to use to server version (npm install), I get the following error

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Any ideas why?

Thanks

  • I think you need to export the module. Please check the purpose of export. https://stackoverflow.com/questions/5311334/what-is-the-purpose-of-node-js-module-exports-and-how-do-you-use-it?rq=1 – Wajahat Qasim May 21 '18 at 06:31

1 Answers1

0

I think you forgot to export your component somewhere i.e.

import React from 'react';
class Comp1 extends React.Component {
 //code here
}

export default Comp1;
Himanshu Pandey
  • 688
  • 2
  • 8
  • 15