【发布时间】:2018-04-16 17:19:55
【问题描述】:
我创建 reactjs 组件并使其在 npm 上发布。我将它安装在我的另一个项目中,现在当我尝试导入它时给出完整路径,例如
import RippleIcon from '../node_modules/rippleicon/src/RippleIcon';
它给了我一个错误
./node_modules/rippleicon/src/RippleIcon.js
Module parse failed: Unexpected token (10:8)
You may need an appropriate loader to handle this file type.
| render() {
| return (
| <i className={this.props.icon+" RippleIcon"}/>
| );
| }
rippleicon 是我的 npm 包名称,我在 create-react-app 上创建我的包。欢迎任何建议。谢谢。
这是我的 package.json
{
"name": "packagetesting",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-scripts": "1.1.4",
"rippleicon": "^0.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
【问题讨论】:
标签: reactjs npm package npm-install