Search code examples
javascriptnpmsassnode-sass

Error when trying to run node-sass via npm


I am trying to run node-sass via npm.

Here is my package.json:

{
  "name": "my-project",
  "version": "1.0.0",
  "description": "Website",
  "main": "index.js",
  "scripts": {
    "sass": "node-sass -w scss/ -o dist/css/ --recursive"
  },
  "author": "Me",
  "license": "ISC",
  "dependencies": {}
}

It installs correctly, but when I try and run the command "npm run sass", I receive the error below:

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

My folder structure: package.json package-lock.json scss (folder) dist (folder) > css (folder) node_modules (folder)

This script used to work fine some time ago on other projects, but now is not. What am I doing wrong?


Solution

  • I was able to fix this issue. I changed the script to

    "sass": "node-sass -w scss/ -o dist/css"

    and it worked. I re-added --recursive and all worked as intended (same script as in original question). I'm not sure where I went wrong exactly, but glad it's fixed.