就这么个小页面,导入 antd,编译就报错!(消耗长时间编译)
`
./src/pages/demo/Life.jsModule not found: Can't resolve 'antd' in 'E:\ReactAntd\reactantd\src\pages\demo'
`
报错1:Module not found: Can't resolve 'antd' in
报错2:JavaScript heap out of memory
删除导入的 antd 和 antd.css 就没问题了。
删除了node_modules,重新install,没用。
`import React from 'react';
import {Button} from 'antd';
import 'antd/dist/antd.css';
import './index.css';
export default class Life extends React.Component{
constructor(props) {
super(props);
this.state = {
count: 0
};
}
handleAdd=()=>{
this.setState({
count: this.state.count + 1
})
}
handleClick(){
this.setState({
count: this.state.count + 1
})
}
render(){
return <div className="content">
<p>React生命周期</p>
<Button onClick={this.handleAdd}>and 点击一下</Button>
</div>
}
}`
看下你的 package.json 里面有没有 antd, 如果有的话. 你重新启动一下项目试试~