Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node-sass is not recognized by command line

I'm trying to set up node-sass, following the instructions on CSS-Tricks. Node and npm are installed correctly, and the node-sass installation worked too. When I go to run node-sass --output-style compressed -o dist/css src/scss, though, I get an error message stating

'node-sass' is not recognized as an internal or external command, operable program or batch file.

I've done a fair bit of Googling and searched Stack Overflow directly. My question isn't about "node" not being recognised as a command. I know node is working as I can run node -v and npm -v, and node-sass was successfully installed after running npm install --save-dev node-sass (there's a folder in node_modules) and no errors appeared in the command line.

Other information: I am running Windows 10 and just did a clean install of node and npm before trying to use node-sass.

EDIT: I uninstalled and reinstalled with -g thanks to @Bhavik's suggestion, and it's now working

like image 764
Sam Woolerton Avatar asked Feb 28 '17 20:02

Sam Woolerton


People also ask

Why is node-Sass not working?

This problem happens because the version of node-sass that you have installed is no longer compatible with the version of node you are trying to run it with.

How do I know if Sass is installed in CMD?

The “-v” command checks the version of SASS you have installed. If you don't have it installed, it will come back as not installed.

How do you check if node-Sass is installed globally?

You can use npx to run node-sass. npx will check if you have a global path to the npm package, and if not, it will temporaily download and execute it. For instance, to run node-sass and check version.


2 Answers

You need to install it globally

npm install -g node-sass

Or add it in package.json

"devDependencies": {
    "node-sass": "4.5.0"
},
"scripts" : {
    "node-sass": "node-sass --output-style compressed -o dist/css src/scss"
}

And then do
1. npm i, which in this case would be similar to npm install --save-dev node-sass
2. npm run node-sass

Reference: npm scripts, npm-run-scripts

like image 136
Bhavik Avatar answered Sep 26 '22 17:09

Bhavik


You can simply run this code

  1. npm install -g sass
  2. sass --watch sass:css

Hopefully work

like image 29
Md Salim Hasan Riad Avatar answered Sep 22 '22 17:09

Md Salim Hasan Riad