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 # Approach 5: using a Node.js version manager.Approach 3: installing into a subdirectory of the home directory.Approach 2: installing into the home directory.Preparation: changing the command line PATH.That’s why this blog post explores alternatives to global installs. The latter requires root access on macOS and some other Unix platforms – which is a considerable downside. (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:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |