找不到模块:无法解析“C:\react-form-validation-demo\src"中的“bootstrap/dist/css/bootstrap-theme.css" [英] Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css' in 'C:\react-form-validation-demo\src'
问题描述
我是 react.js 的新手.我一直在遵循 how-to-do-simple 中的说明-form-validation-in-reactjs 并且我可以运行 http://localhost:3000/>
但是在 index.js
中添加 bootstrap 后,我得到这个错误
无法编译 ./src/index.js 模块未找到:无法解析'bootstrap/dist/css/bootstrap-theme.css' 中'C:\react-form-validation-demo\src'
从'react'导入React;从 'react-dom' 导入 ReactDOM;导入'./index.css';导入 'bootstrap/dist/css/bootstrap.css';导入 'bootstrap/dist/css/bootstrap-theme.css';从'./App'导入应用程序;从 './registerServiceWorker' 导入 registerServiceWorker;ReactDOM.render( , document.getElementById('root'));注册服务工作者();
如果我删除下面这两行,它会起作用:
import 'bootstrap/dist/css/bootstrap.css';导入 'bootstrap/dist/css/bootstrap-theme.css';
在 Bootstrap 版本 4 中,根据 github 中的问题,文件 'bootstrap-theme.css' 已被删除:https://github.com/twbs/bootstrap/issues/21078,在 更改历史记录您可以获得详细信息
要使用第 4 版,请删除导入,否则降级到第 3 版.
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';
In Bootstrap version 4, the file 'bootstrap-theme.css' have been removed, according to issue in github: https://github.com/twbs/bootstrap/issues/21078, in Change History you get detail
To use version 4 remove the import this, or else downgrade to version 3.
这篇关于找不到模块:无法解析“C:\react-form-validation-demo\src"中的“bootstrap/dist/css/bootstrap-theme.css"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!