
If prefix is set on the command line, then non-global commands are forced to run in the given folder.

#Npm config set registry to default install#
This is the location where global items are installed, which by default is the install location of npm itself. Whether or not to show detailed information when running npm ls and npm search. Default: the group ID of the current process.This parameter tells npm which system group to use when running package scripts in global mode as the root user. The location of the config file to read for global configuration options. In this case, the config map should be used, like this: /share/man. Within your package.json project file you can set parameters as well. In some cases you might want to use -save-dev or even -save-optional, so it wouldn't make sense to use npmrc. Many of them can be used within an npm command as a flag, prefixed with -.įor example, if you're installing a new package from the registry and want to save it to your package.json file, you'll want to use the -save flag, but that might not always be the case. Not all parameters need to be permanently set in a file or environment variable. For example, a great way to configure a Docker instance is to set environment variables from the dockerfile. So that way you can do things like export npm_config_registry=localhost:1234.Ī lot of people are use to using environment variables for configuration, so this should be familiar to them. You can also set any npm parameter by prefixing an environment variable with npm_config_. Some examples are NODE_ENV and HTTPS_PROXY. There are a few enironment variables that npm will use over parameters set locally (or in an npmrc file). So, for example, you'd probably want to set https-proxy in the global npmrc file as opposed to the project-level npmrc file since all projects on the system will need the proxy settings. The file you use should depends on the parameter and scope you're wanting to set. Built-in npm config file: /path/to/npm/npmrc.Per-project config file: /path/to/my/project/.npmrc.The four locations where the files may reside are: Npm allows you to use a few different rc files, much like ~/.bashrc, to set your configurations. Depending on your use-case, utilize the different purposed for things like testing, project-specific configuration, global configuration, etc. Unless otherwise noted, all of the parameters below can be set through a few different methods, each of which I'll describe briefly here.

#Npm config set registry to default how to#
I'll also be adding examples of some of the more confusing parameters, so if you know how to use some of the more undocumented options, like searchopts, I'd love to see an example! Setting Parameters Hopefully that way if the help docs confuse you (or don't have enough information), my description will give some more insight in to whatever you're looking for. I ended up learning a lot about npm that will help me out a bunch in the future.įor the most part, I tried to write up a unique description of each parameter (different from the help docs). Not only do I think this could be helpful to the readers, but it was extremely helpful to me to look through all the different flags/parameters and to actually test them out. After reading some of the help documentation recently, I thought it would be helpful to write up details on as many of the npm configurations as possible.

Throughout my use of Node, I only ever knew the basic npm commands like save, install, and publish, and even then I didn't really know the optional parameters that went along with them. Package management can really make or break a language, so ensuring that it is easy to use and flexible is extremely important. The Node Package Manager, or npm, is one of the best parts about Node, in my opinion.
