3

cmd.exe /D /C call C:\Users\sebas\AppData\Roaming\npm\node-sass.cmd style.scss:style.css An output directory must be specified when compiling a directory

enter image description here

The scss file I want the file watcher to watch is placed at the root of my project.

Watch the error appear: gif_link

How do I fix this error?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Sebastian Nielsen
  • 3,835
  • 5
  • 27
  • 43
  • 3
    Your `Arguments` field content in File Watcher **is wrong**. It's for Ruby-sass, not node-sass. Run `node-sass --help` to check expected parameters. For example `--output . $FileName$` will output compiled version in the same folder as source file. https://postimg.cc/LqksNkqL – LazyOne Jul 18 '19 at 22:16
  • @LazyOne That is not true. As Lena's explain in her answer, all I had to do was to check the "Create output file from stdout". The arguments are valid commands for node-sass npm. Please consider removing your comment to avoid confusing others (I unfortunately can't take back my upvote for some reason). – Sebastian Nielsen Jul 19 '19 at 19:37
  • 1
    Check again. 1) Node-sass does not have `$FileName$:$FileNameWithoutExtension$.css` syntax. To specify output file you need to use `-o` / `--output` option; 2) "Create output file from stdout` does not always work (on some systems/setups; no ideas why). That's why `-o` / `--output` parameter comes instead as it always works. – LazyOne Jul 19 '19 at 20:18
  • If just ticking "Create output file from stdout" option works for you then it's great, no probs. – LazyOne Jul 19 '19 at 20:27
  • I am pretty sure `$FileName$:$FileNameWithoutExtension$.css` is the syntax of the jetbrains "file watcher" plugin in then, all I can say is that it isn't incorrect syntax, and *therefore*, your statement: *"Your Arguments field content in File Watcher is wrong. It's for Ruby-sass, not node-sass."* Is wrong. As your comment is wrong and misleading for users to come, I believe that it would be ideal to delete it. – Sebastian Nielsen Jul 19 '19 at 23:10

3 Answers3

4

If you like the .css files to be generated in the same folder as original file, try the following settings:

enter image description here

Note the Create output file from stdout option - it has to be enabled, as node-sass writes CSS to stdout unless the -o option is passed.

If you like to place generated files in a separate folder, use the -o option:

enter image description here

lena
  • 90,154
  • 11
  • 145
  • 150
1

I got same error working with webpack bundler and setting my scripts in package.json

In my case to resolve this issue you need to add output directory ( -o name-of-directory).

If working with scripts in package.json it should look like this:

scripts: {
    "scss": "node-sass --watch src -o src"
}

src is folder where sass file which I want to compile is placed.

It means compile sass from src folder and send compiled files to src folder.

In this case css file will be placed on same place where sass file already is.

Predrag Davidovic
  • 1,411
  • 1
  • 17
  • 20
0

With node-sass for me is working to set Arguments to $FileName$ -o . $FileNameWithoutExtension$.css

and unchecked "Create output file from stdout".

Petr Pánek
  • 369
  • 3
  • 6