10

I see a lot of examples on the internet, that say:
1. install a node package using: npm install package for example npm install node-sass
2. to run the package from the commandline just call the package + arguments like so:
node-sass --output-style compressed -o dist/css src/scss

I'm new to node.js and I'm probably doing something wrong or I just don't understand it yet, but I have to do the following to use the package from the commandline:
node node_modules/node-sass --output-style compressed -o dist/css src/scss

What am I doing wrong?

1 Answers1

11

You're on the right track. If installing locally (without -g option) as you did, you have to manually dig what's included in a package. But check out node_modules/.bin, since that is where any command line tools are placed.

Typically any package that provides binaries is installed with npm install -g package that performs a system install. Binaries from globally installed packages are in path and work form the command line as expected. So maybe this is the option that would work the best for you.

pspi
  • 11,189
  • 1
  • 20
  • 18
  • Ahhh I beginning to understand. I didn't know about the .bin folder. It also seems that an npm script has access to this .bin folder. – projectIncomplete Mar 21 '16 at 13:48
  • Yeah, npm scripts have .bin in PATH and this is super useful for example when using prepublish script to do transpiling etc, check out http://bytearcher.com/articles/use-prepublish-script-to-automate-bower/ for more info on this. – pspi Mar 27 '16 at 08:14