Sunday, 16 April 2017

Multiple strange errors when trying to import React component from local npm package

I have a npm package of React components and an example Meteor.js app which will be used to display their usage. To install my local npm package I ran npm install --save ../library and it successfully added the dependency as "library": "file:///path/to/lib".

However, when I import one of the components and try to use them, the console spams 29 errors, starting with:

Uncaught SyntaxError:
    Unexpected token import
Uncaught TypeError: 
    Cannot read property 'meteorInstall' of undefined
Uncaught TypeError: 
    Cannot read property 'meteorInstall' of undefined
Uncaught TypeError: 
    Cannot read property 'meteorInstall' of undefined
Uncaught TypeError: 
    Cannot read property 'meteorInstall' of undefined
Uncaught TypeError: 
    Cannot read property 'meteorInstall' of undefined
Uncaught TypeError: 
    Cannot read property 'Random' of undefined
Uncaught TypeError: 
    Cannot read property 'meteorInstall' of undefined
Uncaught TypeError: 
    Cannot read property 'MongoID' of undefined

The code:

import React, { PropTypes } from 'react';
import Button from 'library/components/button/Button.jsx'

export default class App extends React.Component {

  render() {
      return (
          <div>
              <Button>Click Me</Button>
          </div>
    );
  }
}

Removing the <Button/> component and it's import removes the error. What is going on here?



via Orbit

No comments:

Post a Comment