Question

Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css' in 'C:\react-form-validation-demo\src'

I am newbie in react.js. I have been following instruction in how-to-do-simple-form-validation-in-reactjs and I can run http://localhost:3000/

But after adding bootstrap in index.js, I got this error

Failed to compile ./src/index.js Module not found: Can't resolve
'bootstrap/dist/css/bootstrap-theme.css' in
'C:\react-form-validation-demo\src'
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

If I remove these two lines below, it works:

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
 46  227709  46
1 Jan 1970

Solution

 26

In Bootstrap version 4, the file 'bootstrap-theme.css' has been removed, according to the issue on GitHub. See the change history for details.

If you want to continue using version 4, remove this import, else downgrade to version 3.

2018-07-02

Solution

 21

Adding the solution to the cause I ran into - it was my miss, but still unclear when reading the other answers.

If react-bootstrap is installed solo like this:

npm install --save react-bootstrap

then bootstrap will be missing. Try the following to correct:

npm install --save bootstrap

The correct way to install initially is as follows:

npm install --save react-bootstrap bootstrap
2021-05-09