Angular 2 Node Bourbon Error

我们两清 提交于 2019-12-01 21:51:30

问题


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)

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?!


回答1:


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.

Link to the issues:

  • 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’

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

npm install sass-loader@6.0.7

Related question I am not able to use node-bourbon in the project



来源:https://stackoverflow.com/questions/48298848/angular-2-node-bourbon-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!