Advanced
Adding Local node_modules/.bin to $PATH
node_modules/.bin to $PATHTo 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.jsonand usingnpm run script:name.Using the
npxprefix and usingnpx nr script.name.Installing
nrglobally.
To do so, in your shell configuration file, add the line:
export PATH="$PATH:$(npm root)/.bin"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:
> which nr
/path/to/your/project/node_modules/.bin/nrNow, to run a package script:
nr script.nameThis approach also lets you run any other local NPM package that defines an executable, such as vite, vitest, tsc, eslint, etc.
Last updated