角度2节点波旁威士忌误差 [英] Angular 2 Node Bourbon Error

查看:101
本文介绍了角度2节点波旁威士忌误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ERROR in ./node_modules/css-loader?
{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-
loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/sass-
loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":
[]}!./src/styles.scss
Module build failed: 
var path = require('path');
^
  Invalid CSS after "v": expected 1 selector or at-rule, was "var path 
  = require("
     in 
  /home/dada/AngularProjects/playground2/node_modules/bourbon/index.js 
(line 1, column 1)

您好...我试图在Angular 2项目中使用bourbon,但是当我安装该软件包并尝试在sass文件中导入bourbon时,出现以下错误?有什么想法吗?!

Hello... I'm trying to use bourbon in my Angular 2 project but when I install the package and try to import bourbon in my sass files I get the following errors? any ideas?!

推荐答案

当我有一个通过导入语句引用Burbon的节点模块时,我遇到了同样的问题.事实证明,版本7的sass-loader具有一项功能,即它不会在同一个JavaScript文件中选择sass文件.

I came across this same issue when I had a node module that was referencing Burbon through an import statement. It turns out that version 7 of sass-loader has a feature where it doesn’t select the sass file over the same named JavaScript file.

链接到问题:

  • https://github.com/webpack-contrib/sass-loader/issues/556
  • https://github.com/angular/angular-cli/issues/10535

此问题有两种不同的解决方法. 首先,您可以在导入语句中添加扩展名,尽管我还没有亲自测试过这种方法.

There are two different work arounds to this issue. First you can add extension to your import statements, though I haven’t tested this approach personally.

@import ‘./cool-sass-file’ becomes @import ‘./cool-sass-file.scss’

第二条路线,我验证了是将sass-loader回滚到版本6.0.7

The second route, which I verified was to roll back sass-loader to version 6.0.7

npm install sass-loader@6.0.7

相关问题 我无法在项目

这篇关于角度2节点波旁威士忌误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆