Advanced
Adding Local node_modules/.bin
to $PATH
node_modules/.bin
to $PATH
To save time when issuing commands to nr
, you can append ./node_modules/.bin
to your $PATH
environment variable, which will allow you to run locally-installed versions of NPM package executables from the command line. This approach is preferable to:
Aliasing the script in
package.json
and usingnpm run script:name
.Using the
npx
prefix and usingnpx nr script.name
.Installing
nr
globally.
To do so, in your shell configuration file, add the line:
It is important to append the local NPM bin path to your PATH to prevent malicious actors from creating packages that define binaries that shadow system-level programs (ie: ssh
).
To ensure your shell is configured correctly, run which nr
from your project's root directory. You should see the following output:
Now, to run a package script:
This approach also lets you run any other local NPM package that defines an executable, such as vite
, vitest
, tsc
, eslint
, etc.
Last updated