
npm adds links from it into the global node_modules – e.g.: /usr/local/bin/tsc ->. This directory is part of the macOS PATH by default. Second, a bin directory which contains executable files: % npm bin -global Under that prefix, there are two important subdirectories.įirst, a node_modules directory: % npm root -global We can display the current prefix as follows (I’m showing the results for my Mac): % npm config get prefix The npm documentation recommends to change the npm prefix. On Unix, we can display it like this: echo $PATH

On Windows, we can display the current PATH like this: $env:PATH There are many good tutorials online, just do a web search for: If we want to install executables via npm, it’s important that the PATH is set up correctly. This PATH is a command line variable that lists all paths where the command line looks for executables when we enter a command. In the remainder of this blog post, we need to change the command line PATH for some approaches. Preparation: changing the command line PATH #

(Instead of the long version -global of this flag, we can also use the shorter -g.) Globally, into a global node_modules directory: npm install -global some-package Locally, into a node_modules directory that npm searches for (or creates) in the current directory and its ancestors: npm install some-package There are two ways in which npm packages can be installed:
