我有一个反应组件的npm包和一个示例Meteor.js应用程序,它将用于显示它们的用法。要安装我的本地npm包,我运行npm install --save ../library
并成功将依赖项添加为"library": "file:///path/to/lib"
。
但是,当我导入其中一个组件并尝试使用它们时,控制台会发出29个错误,从以下开始:
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
代码:
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>
);
}
}
删除<Button/>
组件及其导入会删除错误。这是怎么回事?
编辑:深入挖掘,如果我点击Unexpected token import
错误,它会向我显示我在库Button
组件中导入React的行。该问题可能与某种方式无法正确理解ES6进口吗?