在使用 yarn add gulp-sass命令安装sass后,执行gulp style,报错如下:
$ C:\Users\45818\lagoufed-e-task\part2\fed-e-task-02-01\code\pages-boilerplate\node_modules\.bin\gulp style
[06:54:39] Using gulpfile ~\lagoufed-e-task\part2\fed-e-task-02-01\code\pages-boilerplate\gulpfile.js
[06:54:39] Starting 'style'...
Error in plugin "gulp-sass"
Message:
Both the `sass` and `node-sass` packages are permitted.
For example, in your gulpfile:
var sass = require('gulp-sass')(require('sass'));
[06:54:39] The following tasks did not complete: style
[06:54:39] Did you forget to signal async completion?
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
报错原因:因为node-sass被弃用了
解决方案:
使用下面命令安装sass
npm install sass gulp-sass --save-dev
在js中引用如下:
const sass = require( 'gulp-sass' )( require ( 'sass' ) );