npm install -g antd
npm WARN antd@3.10.8 requires a peer of react@>=16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN antd@3.10.8 requires a peer of react-dom@>=16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ant-design/icons-react@1.1.2 requires a peer of react@16.x but none is installed. You must install peer dependencies yourself.
npm WARN create-react-context@0.2.3 requires a peer of react@^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN rc-editor-mention@1.1.11 requires a peer of react@>=15.x but none is installed. You must install peer dependencies yourself.
npm WARN rc-editor-mention@1.1.11 requires a peer of react-dom@>=15.x but none is installed. You must install peer dependencies yourself.
npm WARN rc-switch@1.8.0 requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN rc-switch@1.8.0 requires a peer of react-dom@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-slick@0.23.2 requires a peer of react@^0.14.0 || ^15.0.1 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-slick@0.23.2 requires a peer of react-dom@^0.14.0 || ^15.0.1 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-lazy-load@3.0.13 requires a peer of react@^0.14.0 || ^15.0.0-0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-lazy-load@3.0.13 requires a peer of react-dom@^0.14.0 || ^15.0.0-0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN draft-js@0.10.5 requires a peer of react@^0.14.0 || ^15.0.0-rc || ^16.0.0-rc || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN draft-js@0.10.5 requires a peer of react-dom@^0.14.0 || ^15.0.0-rc || ^16.0.0-rc || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN rc-hammerjs@0.6.9 requires a peer of react@^0.14.3 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
+ antd@3.10.8
added 115 packages in 60.12s
查看react 版本
npm info react
先安装
npm install react-native -g
npm install --save react@16.3.1
npm install -g react-dom
npm WARN react-dom@16.6.3 requires a peer of react@^16.6.3 but none is installed. You must install peer dependencies yourself.
npm install --save react@16.6.3
npm WARN react-dom@16.6.3 requires a peer of react@^16.6.3 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ react@16.3.1
added 7 packages and updated 1 package in 179.662s
未安装成功
引入 Can't resolve 'antd/dist/antd.css 报错
Can't resolve 'antd/lib/button'
App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import Button from 'antd/lib/button';
// import { Button } from 'antd';
import 'antd/dist/antd.css';
import './App.css';
// class App extends Component {
// render() {
// return (
// <div className="App">
// <Button type="primary">Button</Button>
// </div>
// );
// }
// }
class App extends Component {
render() {
return (
<div className="App">
<div className="App">
<Button type="primary">Button</Button>
</div>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
}
export default App;