在安装react-bootstrap之前是否需要安装React

时间:2016-12-23 10:36:28

标签: node.js twitter-bootstrap reactjs react-bootstrap

我正在尝试安装react-bootstrap。当我运行命令

npm install react-bootstrap --save

我得到以下内容(某些路径名称替换为“...”):

npm WARN saveError ENOENT: no such file or directory, open '/Users/../package.json'/Users/.../..

├── UNMET PEER DEPENDENCY react@>=0.14.0  
├─┬ react-bootstrap@0.30.7  
│ ├─┬ babel-runtime@6.20.0   
│ │ ├── core-js@2.4.1   
│ │ └── regenerator-runtime@0.10.1   
│ ├── classnames@2.2.5   
│ ├── dom-helpers@2.4.0   
│ ├─┬ invariant@2.2.2   
│ │ └─┬ loose-envify@1.3.0   
│ │   └── js-tokens@2.0.0   
│ ├── keycode@2.1.8   
│ ├── UNMET PEER DEPENDENCY react@>=0.14.0  
│ ├── UNMET PEER DEPENDENCY react-dom@>=0.14.0  
│ ├─┬ react-overlays@0.6.10   
│ │ └── UNMET PEER DEPENDENCY react@>=0.14.0  
│ ├── react-prop-types@0.4.0   
│ ├── uncontrollable@4.0.3   
│ └── warning@3.0.0   
└── UNMET PEER DEPENDENCY react-dom@>=0.14.0  

npm WARN enoent ENOENT: no such file or directory, open '/Users/../../package.json'  
npm WARN react-bootstrap@0.30.7 requires a peer of react@>=0.14.0 but none was installed.  
npm WARN react-bootstrap@0.30.7 requires a peer of react-dom@>=0.14.0 but none was installed.  
npm WARN react-overlays@0.6.10 requires a peer of react@>=0.14.0 but none was installed.  
npm WARN react-overlays@0.6.10 requires a peer of react-dom@>=0.14.0 but none was installed.  
npm WARN uncontrollable@4.0.3 requires a peer of react@>=0.11.0 but none was installed.  
npm WARN react-prop-types@0.4.0 requires a peer of react@>=0.14.0 but none was installed.  

我的问题是:我是否需要在安装react-bootstrap之前安装React ?在doc中没有看到任何具体的提及。 (我是React的新手,如果我正在使用react-bootstrap,我甚至不知道我还需要React。我认为它也包含了React。但是后来在同一个doc的Javascript部分看到了这个:如果您安装了React设置并安装了React-Bootstrap,那么您将获得所需的一切。“)

2 个答案:

答案 0 :(得分:1)

在React生态系统中,您应该始终先安装react + react-dom。一般来说,不要依赖于对等依赖。

答案 1 :(得分:1)

是的,您需要单独安装react和react-dom。对等依赖项是指您安装的软件包假定已经安装的依赖项。

行为在npm 3中发生变化,只是警告那些缺失的行为。

npm install react react-dom react-bootstrap --save