问题描述
在运行node-sass时使用"--watch"或"-w"标志时,我遇到了问题.我已经将node-sass安装为devDependency,并为我指定了一个脚本来运行node-sass.问题是,当我运行不带任何标志的脚本时,一切正常,并且SCSS代码已编译,但是当我添加"--watch"标志时,它甚至不会编译初始代码,也不会检测到任何文件变化.我做了很多研究,却一无所获.我将脚本放在下面,很高兴提供其他可能有助于解决此问题的信息.
I am having a problem when using the "--watch" or "-w" flag when running node-sass. I've installed node-sass as a devDependency and specified a script for me to run node-sass. The thing is that when I run the script without any flags everything works fine and the SCSS code is compiled, but when I add the "--watch" flag, it won't even compile the initial code, nor will it detect any file changes. I've done a lot of research and found nothing. I'll leave the scripts down below and I'll be glad to provide any other information that may help with solving this issue.
在 package.json 内部:
"scripts": {
"compile:sass": "node-sass sass/main.scss css/style.css"
}
当我运行 npm run compile:sass
并获得以下输出时,此方法工作正常:
This works fine when I run npm run compile:sass
and I get this output:
[email protected] compile:sass /Users/lucabarcelos/WebstormProjects/AdvancedCSS/Natours
node-sass sass/main.scss css/style.css
Rendering Complete, saving .css file...
Wrote CSS to /Users/lucabarcelos/WebstormProjects/AdvancedCSS/Natours/css/style.css
但是当我将脚本更改为此:
But when I change the script to this:
"scripts": {
"compile:sass": "node-sass sass/main.scss css/style.css -w"
}
我得到以下输出:
[email protected] compile:sass /Users/lucabarcelos/WebstormProjects/AdvancedCSS/Natours
node-sass sass/main.scss css/style.css -w
它一直在等待文件更改,但是当我实际更改时,什么都没有发生.
And it keeps waiting for file changes but when I actually change something nothing happens at all.
推荐答案
我在进行相同的natours ;-)过程时遇到了相同的问题.这与node-sass的版本有关.
I had the same problem doing the same natours ;-) course. It's something to do with the version of node-sass.
然后使用以下版本安装版本4.5.3
Then install version 4.5.3 with;
如果这不起作用,请查看https://github.com/jonasschmedtmann/advanced-css-course/blob/master/npm-fixes.md
If this doesn't work, check out https://github.com/jonasschmedtmann/advanced-css-course/blob/master/npm-fixes.md
这篇关于使用--watch标志时,Node-sass不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!