I am trying to use sass in a NodeJS project and this is the library I installed with nodejs
https://www.npmjs.org/package/node-sass
I am using webstorm for this project and I can't get the Sass file watcher to work.
Even after I save the filewatcher and click "Ok", the filewatcher does not work. When I open the settings to check what's wrong the filewatcher has been unchecked. Here are the filewatcher settings:
The node-sass module is installed as a global module so the node-sass command works.
A configured File Watcher can be saved in your project settings or in the IDE settings and used in different projects. When you open a file where a predefined File Watcher is applicable, WebStorm displays a pane where suggests activating it.
When WebStorm detects that you’re using a type of File which it can “watch” for you, it will prompt you to set up a File Watcher (or you can customize your own). From this panel, you can see this File Watcher will do the following: Watch for changes on all TypeScript files (within the defined scope)
Phpstorm file watcher does not work very well with node-sass (tested in Phpstorm 8.0.1 windows) Show activity on this post. Phpstorm 8.0.3 Windows 7 (x64) node-sass installed globally working example
The file has the name of the source Sass, Less, or SCSS file and the extension .css. The location of the generated files is defined in the Output paths to refresh field of the New Watcher dialog. However, in the Project Tree, they are shown under the source file which is now displayed as a node.
Usage: node C:\Users\USER\AppData\Roaming\npm\node_modules\node-sass\bin\node-sass
[options]
<input.scss>
[<output.css>
]Options: --output-style CSS output style (nested|expanded|compact|compressed) [default: "nested"] --source-comments Include debug info in output (none|normal|map) [default: "none"] --include-path Path to look for @import-ed files [default: "C:\\Users\\USER\\AppData\\Roaming\\npm"] --watch, -w Watch a directory or file --output, -o Output css file --stdout Print the resulting CSS to stdout --help, --help Print usage info
the simplest setup looks as follows:
Program: C:\Users\USER\AppData\Roaming\npm\node-sass.cmd
Arguments: $FileName$ $FileNameWithoutExtension$.css
Working directory: $FileDir$
Output paths to refresh: $FileNameWithoutExtension$.css
'Create output from stdout' should be off
With such settings the generated .css file will be placed near the original .scss. If you like to put resultant files into a different folder, try playing with -o
option. Like:
Arguments: $FileName$ -o $ProjectFileDir$/css/$FileNameWithoutExtension$.css
Output paths to refresh: $ProjectFileDir$/css/$FileNameWithoutExtension$.css
Most definitely path to .cmd is wrong as lena and lazy one suggested. Whenever watcher unchecks in Web/Phpstorm its probably because of invalid path. If you still have trouble with node-sass you could always go Ruby way.
gem install sass
, C:\Ruby200\bin\sass.bat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With