Do I need to install React before I install react-bootstrap

409 Views Asked by At

I am trying to install react-bootstrap. When I run the command

npm install react-bootstrap --save

I get the following (some path names replaced with '...') :

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

├── UNMET PEER DEPENDENCY react@>=0.14.0  
├─┬ [email protected]  
│ ├─┬ [email protected]   
│ │ ├── [email protected]   
│ │ └── [email protected]   
│ ├── [email protected]   
│ ├── [email protected]   
│ ├─┬ [email protected]   
│ │ └─┬ [email protected]   
│ │   └── [email protected]   
│ ├── [email protected]   
│ ├── UNMET PEER DEPENDENCY react@>=0.14.0  
│ ├── UNMET PEER DEPENDENCY react-dom@>=0.14.0  
│ ├─┬ [email protected]   
│ │ └── UNMET PEER DEPENDENCY react@>=0.14.0  
│ ├── [email protected]   
│ ├── [email protected]   
│ └── [email protected]   
└── UNMET PEER DEPENDENCY react-dom@>=0.14.0  

npm WARN enoent ENOENT: no such file or directory, open '/Users/../../package.json'  
npm WARN [email protected] requires a peer of react@>=0.14.0 but none was installed.  
npm WARN [email protected] requires a peer of react-dom@>=0.14.0 but none was installed.  
npm WARN [email protected] requires a peer of react@>=0.14.0 but none was installed.  
npm WARN [email protected] requires a peer of react-dom@>=0.14.0 but none was installed.  
npm WARN [email protected] requires a peer of react@>=0.11.0 but none was installed.  
npm WARN [email protected] requires a peer of react@>=0.14.0 but none was installed.  

Do I need to install React before I install react-bootstrap? I don't see any specific mention of it in the doc. (I am new to React and didn't even know that I need React also if I am using react-bootstrap. I thought it included React as well. But saw this mentioned in the Javascript section of the same doc later: "If you have React setup and React-Bootstrap installed you have everything you need.")

2

There are 2 best solutions below

0
On BEST ANSWER

In the React ecosystem, you should always install react + react-dom first. Don't rely on peer dependencies in general.

0
On

Yes you will need to install react and react-dom separately. A peer dependency is one that the package you're installing assumes to already be installed.

The behaviour changed in npm 3 to simply warn of those that are missing.

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