node-sass command not found when compiling
Asked Answered
L

9

14

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?

Lysippus answered 5/9, 2016 at 12:33 Comment(7)
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.Roussel
I tried both ways. Nothing works...Lysippus
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 ...Roussel
Strange, but it didn't working. Maybe i doing something wrong. On Windows in's working goodLysippus
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?Roussel
/usr/local/bin/node-sass: No such file or directory - I get this errorLysippus
That means it isn't installed globally. Are you using a Node version manager like nvm or something?Roussel
F
15

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.

Filterable answered 18/9, 2017 at 11:1 Comment(0)
A
12

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

Absorbance answered 19/8, 2019 at 1:57 Comment(1)
could you add a description as to what does this statement do?Dibrin
S
6

This helped me:

sudo npm install --unsafe-perm -g node-sass
Standfast answered 29/1, 2020 at 13:57 Comment(1)
Worked! I missed --unsafe-perm and it caused issues in linux for node-sass moduleHemangioma
U
3

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.

Unfrequented answered 3/10, 2017 at 0:27 Comment(0)
S
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
Suctorial answered 22/3, 2018 at 12:57 Comment(0)
C
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
Commentate answered 5/11, 2018 at 11:22 Comment(0)
S
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
Simmie answered 21/5, 2019 at 4:21 Comment(0)
V
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).

Valerle answered 15/4, 2020 at 23:40 Comment(0)
U
0

I tried an npm install but that didn't install the node-sass binary. I ended up having to run

yarn --cwd assets

Unfrock answered 24/8, 2022 at 16:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.