无法解析“node_modules/bootstrap/scss/bootstrap”

问题描述 投票:0回答:2

Parcel编译时,出现此错误:

@parcel/core: Failed to resolve '../node_modules/bootstrap/scss/bootstrap'

我的

app.css
文件:

@import '../node_modules/bootstrap/scss/bootstrap.scss';
@import './styles/style.scss';
@import './styles/plugins/plugins.scss';
@import './styles/plugins/plugins.css';
@import './styles/loader.scss';
@import './styles/custom.css';

为什么 Parcel 无法识别正确的引导 SCSS?

twitter-bootstrap parcel
2个回答
3
投票

我无法解释为什么会这样,但创建一个单独的文件可以解决问题:

@import './styles/bootstrap.scss';

然后在

bootstrap.scss

@import 'node_modules/bootstrap/scss/bootstrap.scss';

0
投票

为了使用 scss,您需要安装 sass 并且您的 css 文件必须具有 scss 扩展名。所以试试这个:

  1. 从项目目录安装 sass:
    npm install -g sass
  2. 将 app.css 文件重命名为 app.scss 并使用它重构其他文件。
© www.soinside.com 2019 - 2024. All rights reserved.