11

I have a problem with SASS for node.js on Mac (OS X El Capitan)

When i trying compile a scss file to css using command 'node-sass -o css sass/style.scss' I get the following error:

node-sass: command not found

What's the problem and how i can solve it?

Ahmad
  • 4,708
  • 7
  • 37
  • 50
Jameson
  • 147
  • 1
  • 3
  • 11
  • 6
    Did you install the package globally (`npm install -g node-sass`) or locally? If locally, the CLI tool can be called as `./node_modules/.bin/node-sass`. – robertklep Sep 05 '16 at 12:44
  • I tried both ways. Nothing works... – Jameson Sep 05 '16 at 12:46
  • When it's installed globally, you need to have `/usr/local/bin` in your `$PATH` environment variable. Or call it with a full path: `/usr/local/bin/node-sass -o ...` – robertklep Sep 05 '16 at 12:47
  • Strange, but it didn't working. Maybe i doing something wrong. On Windows in's working good – Jameson Sep 05 '16 at 12:50
  • What does this return: `ls -al /usr/local/bin/node-sass`? It's working fine on my Mac so it's not OS-related. Are you using `nvm` or another Node version manager? – robertklep Sep 05 '16 at 12:53
  • /usr/local/bin/node-sass: No such file or directory - I get this error – Jameson Sep 05 '16 at 12:58
  • That means it isn't installed globally. Are you using a Node version manager like `nvm` or something? – robertklep Sep 05 '16 at 13:18

8 Answers8

8

It means command node-sass is missing in your system. node-sass is a node.js command which can be installed with

npm install -g node-sass

The -g switch means a node.js command which can run globally is being installed. Without -g means a node.js library is being installed at current directory.

CDT
  • 8,269
  • 15
  • 55
  • 89
6

try this: npx node-sass -o css sass/style.scss

npx will check whether <command> exists in $PATH, or in the local project binaries, and execute it. The more detail explanation is here

hustnzj
  • 71
  • 2
  • 4
3

This helped me:

sudo npm install --unsafe-perm -g node-sass
vladanPro
  • 417
  • 5
  • 14
2

In my case, I was getting errors like this because npm install didn't run correctly. removing my node_modules and then rerunning that command removed my build errors.

S. Buda
  • 514
  • 3
  • 25
0

go to https://github.com/sass/node-sass download .zip or clone repo add el folder node-sass in node-modules and en file package-lock.json add this.

"node-sass": {
  "version": "4.7.2",
  "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.7.2.tgz",
  "integrity": "sha512-CaV+wLqZ7//Jdom5aUFCpGNoECd7BbNhjuwdsX/LkXBrHl8eb1Wjw4HvWqcFvhr5KuNgAk8i/myf/MQ1YYeroA==",
  "dev": true,
  "requires": {
    "async-foreach": "0.1.3",
    "chalk": "1.1.3",
    "cross-spawn": "3.0.1",
    "gaze": "1.1.2",
    "get-stdin": "4.0.1",
    "glob": "7.1.2",
    "in-publish": "2.0.0",
    "lodash.assign": "4.2.0",
    "lodash.clonedeep": "4.5.0",
    "lodash.mergewith": "4.6.1",
    "meow": "3.7.0",
    "mkdirp": "0.5.1",
    "nan": "2.8.0",
    "node-gyp": "3.6.2",
    "npmlog": "4.1.2",
    "request": "2.79.0",
    "sass-graph": "2.2.4",
    "stdout-stream": "1.4.0",
    "true-case-path": "1.0.2"
  },

ok now

~$ npm install
Leonardo Pineda
  • 738
  • 7
  • 9
0

You may try this:

pwd

Checkout to your project directory, for eg:desktop

ls -la

Then see your project name and its position. Whether it’s in root. If its in root,

sudo chown -R <change to your position from root><projectname>/
cd <projectname>
cd ../
rm -rf node_modules/
ls
npm i
Andrey Moiseev
  • 3,068
  • 7
  • 42
  • 58
Afsina
  • 11
  • 2
0

to use sass you must have node installed and than use the following command

sudo npm install -g node-sass

this is for linux users only, if you have not used "sudo" you will get the following error

node-sass not found
0

At the same folder where you have the package.json file, open terminal and type this:

npm install node-sass

If after install this dependency still failling, remove node_modules and type:

npm install

npm install will rebuild your node_modules folder with package.json dependencies updated (Previously, you install node-sass in package.json with 'npm install node-sass' command).

Yair Abad
  • 140
  • 2
  • 5