When working in a Visual Studio 2017 solution I started to get this problem when running sass.js task via task runner explorer.
When googling this problem I found this nice explanation by Ryan Hayes
However I ran into an issue today in which I updated Node.JS outside of Visual Studio, but since VS uses its own install that is separate from any outside installation, you can potentially run into a node_modules package dependency issue where one version of npm installs a package (which makes it rely on that version of Node/npm), and then you can’t run commands in the other version (they break).
Running npm install or npm rebuild node-sass –force, as the error message says, did not help.
How to solve it
- Open Visual Studio 2017
- Go to Tools -> Options…
- Go to Projects and Solutions -> Web Package Management
- move $(PATH) to the top of that list and close that window.
- Now close all running tasks (if any)
- Restart Visual Studio