Search code examples
node.jsnpmnode-sass

node-sass always command not found!!! I try to everything


my os is macOS 10.13, and I using brew install node, actually, before brew, I install node without brew, and still not work too!

I log my install step:

$ npm install -g node-sass

//bla bla bla...done

$ node-sass
-bash: node-sass: command not found

NOT surprisingly! I always need set path!

$ npm config set prefix '~/.npm-global'
$ export PATH=~/.npm-global/bin:$PATH

then

$ node-sass
//Provide a Sass file to render bla bla bla ~~~

When I close terminal or open new terminal label, it's happen too! I still set path, AGAIN!

WHY!!! is macOS 10.13 problem?!

I even install node-saa using -g, I don't remember before macOS 10.13 is it also too!!!

cao someone tell me, why I need always set path? have other way to fix?

THANK YOU VERY MUCH!!!


Solution

  • You should add the new PATH export to your .bash_profile.

    In terminal do the following command: open -a TextEdit ~/.bash_profile (or use nano ~/.bash_profile, if you know how to use it).

    You should see a bunch of export statements at the top of the opened file, put yours (export PATH=~/.npm-global/bin:$PATH) below them. Try reopening a new terminal window and see if node-sass works.