You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装SASS后无法使用--watch命令,执行node-sass报错求助

Fixing node-sass Watch Command Errors

I’ve run into similar issues with recent node-sass versions—let’s break down the two errors you’re seeing and fix them step by step:

1. "ENOENT: no such file or directory, lstat 'style.scss'"

This error is straightforward: node-sass can’t find your style.scss file in the directory where you’re running the command.

  • First, confirm the file exists: run ls (Mac/Linux) or dir (Windows) in your terminal to list files in the current folder. If style.scss isn’t there, either:
    • Move to the correct directory with cd path/to/your/scss/folder, or
    • Use the full relative path to the file in your command, e.g., node-sass src/style.scss --watch --output dist

2. "An output directory must be specified when compiling a directory"

Even if your file exists, recent node-sass builds require explicit output instructions when using the --watch flag. You have two simple fixes here:

Option A: Specify an output directory

Use the --output flag to tell node-sass where to put the compiled CSS. For example, to output to the same folder as your SCSS file:

node-sass style.scss --watch --output ./

Or to a dedicated css folder:

node-sass style.scss --watch --output css/

Option B: Directly specify the output file name

If you want to compile to a specific file (instead of a directory), just add the output file path at the end of the command:

node-sass style.scss style.css --watch

This will compile style.scss to style.css and watch for changes in the SCSS file.

Give either of these a try—they should resolve both errors. I suspect the recent node-sass update tightened up the requirements for watch mode, which is why this started happening suddenly.

内容的提问来源于stack exchange,提问作者newrobot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:22:08