The short answer:
With any locally installed npm
package (ie as a project's devDependancy
), you should not expect to be able to run the package's CLI as follows <package_name> --help
. You will need to include the full path to the module in the .node_moduels/
directory, just as @netweb has shown in his answer:
./node_modules/.bin/stylelint --help
IMHO Stylelint's documentation page is a tad confusing in this regard, which is why I asked the question.
The longer answer:
To be able to run stylelint --help
or any other npm
CLI, you would have to† install the package globally, ie: <package_name> -global
. In that process, a symlink is created so the <package_name>
keyword could be invoked in any directory on the system.
However, there is a category of tools (for example linters) where its usually considered bad practice to install them globally. This is because different projects will likely have conflicting requirements, in which case, having all these tools globally installed quickly becomes problematic. It's best to have these tools installed at the project level as a devDependancy
like so: npm install <package_name> --save-dev
.
If you are setting up an npm
scripts or Continuous Integration systems then you would invoke these tools' CLI by including the path to the local install: ./node_modules/.bin/stylelint "**/*.css"
However, in the terminal, writing the fill path each and every time you want to invoke a tool is painful, so instead, you can use [npx][4]
to invoke the locally installed module:
npx stylelint --help
† npm-link, also symlinks your local package as if it was a globally installed. However, except for some specific scenarios, it's very unlikely you want to make globally available a local devDependancy
.