node-sass: node-sass --watch doesn't work for directories
I noticed that the --watch
command line switch added by #147 isn’t documented in README.md, so I was going to fork and add it, but shortly realized that --watch
doesn’t actually seem to work. A couple issues here:
First of all, I imagine that node-sass --watch
should work without specifying an input file, like the SASS Ruby gem. However, it doesn’t appear to work that way:
peterjmag@peterjmags-iMac ~/node/node-sass-watch
$ node-sass --watch scss/
Compile .scss files with node-sass.
Usage: node-sass [options] <input.scss> [<output.css>]
Options:
[...]
Argument check failed: function (argv){
if (argv.help) { return true; }
if (argv._.length < 1) { return false; }
}
peterjmag@peterjmags-iMac ~/node/node-sass-watch
$ node-sass --watch=scss/
Compile .scss files with node-sass.
Usage: node-sass [options] <input.scss> [<output.css>]
Options:
[...]
Argument check failed: function (argv){
if (argv.help) { return true; }
if (argv._.length < 1) { return false; }
}
If I then add an input file argument (a dummy file for instance, just to satisfy the requirement), I get the following:
peterjmag@peterjmags-iMac ~/node/node-sass-watch
$ ls scss/
test.scss test2.scss
peterjmag@peterjmags-iMac ~/node/node-sass-watch
$ node-sass scss/ --watch=scss/
error reading file "scss/"
peterjmag@peterjmags-iMac ~/node/node-sass-watch
$ node-sass scss/test.scss --watch=scss/
Rendering Complete, saving .css file...
Wrote CSS to /Users/admin/node/node-sass-watch/test.css
[saved a minor change to test2.scss, which triggers the following]
NaN
Rendering Complete, saving .css file...
Wrote CSS to /Users/admin/node/node-sass-watch/test.css
[saved test2.scss again]
NaN
Rendering Complete, saving .css file...
Wrote CSS to /Users/admin/node/node-sass-watch/test.css
It’s also entirely possible that I’m missing something obvious here, so let me know if that’s the case. Either way, I’m happy to update the docs once this is resolved! 😃
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 21 (9 by maintainers)
Use ‘-r’ to recursively watch
node-sass -r --watch scss -o css
I’m sorry for bringing this up again, but I cannot seem to get it to work. I’m trying to
node_modules/node-sass/bin/node-sass assets/scss/main.scss -o static/css/ -w assets/scss/
, but get the following output:I’ve got the same error as @CrowdHailer.
CMD:
Error:
^ Error: ENOENT, no such file or directory ‘C:\sandbox\manager\app\assets\styles\sass*’ at Error (native) at Object.fs.lstatSync (fs.js:792:18) at Object.module.exports.parseDir (C:\Users\user\AppData\Roaming\npm\node_modules\node-sass\node_modules\sass-graph\sass-graph.js:145:10) at watch (C:\Users\user\AppData\Roaming\npm\node_modules\node-sass\bin\node-sass:233:21) at run (C:\Users\user\AppData\Roaming\npm\node_modules\node-sass\bin\node-sass:303:5) at Object.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\node-sass\bin\node-sass:383:3) at Module._compile (module.js:460:26) at Object.Module._extensions…js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12)
Process finished with exit code 1
I also don’t think the watch option works as expected. I am using version 3.0.0 of node-sass this command works fine
however the same with the
--watch
or-w
flag does notI get a no directory error Error: ENOENT, no such file or directory ‘path/to/project/src/styles/**’