| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,6 @@ npm <command> | |||
| 31 | 31 | * [**Documentation**](https://docs.npmjs.com/) - Official docs & how-tos for all things **npm** | |
| 32 | 32 | * Note: you can also search docs locally with `npm help-search <query>` | |
| 33 | 33 | * [**Bug Tracker**](https://github.com/npm/cli/issues) - Search or submit bugs against the CLI | |
| 34 | - * [**Roadmap**](https://github.com/orgs/github/projects/4247/views/1?filterQuery=npm) - Track & follow along with our public roadmap | ||
| 35 | 34 | * [**Community Feedback and Discussions**](https://github.com/orgs/community/discussions/categories/npm) - Contribute ideas & discussion around the npm registry, website & CLI | |
| 36 | 35 | * [**RFCs**](https://github.com/npm/rfcs) - Contribute ideas & specifications for the API/design of the npm CLI | |
| 37 | 36 | * [**Service Status**](https://status.npmjs.org/) - Monitor the current status & see incident reports for the website & registry | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ Note that nested packages will *also* show the paths to the specified packages. | |||
| 23 | 23 | For example, running `npm ls promzard` in npm's source tree will show: | |
| 24 | 24 | ||
| 25 | 25 | ```bash | |
| 26 | - npm@11.6.3 /path/to/npm | ||
| 26 | + npm@11.6.4 /path/to/npm | ||
| 27 | 27 | └─┬ init-package-json@0.0.4 | |
| 28 | 28 | └── promzard@0.1.5 | |
| 29 | 29 | ``` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces. | |||
| 14 | 14 | ||
| 15 | 15 | ### Version | |
| 16 | 16 | ||
| 17 | - 11.6.3 | ||
| 17 | + 11.6.4 | ||
| 18 | 18 | ||
| 19 | 19 | ### Description | |
| 20 | 20 | ||
@@ -64,7 +64,7 @@ In particular, npm has two modes of operation: | |||
| 64 | 64 | npm installs packages into the current project directory, which defaults to the current working directory. | |
| 65 | 65 | Packages install to `./node_modules`, and bins to `./node_modules/.bin`. | |
| 66 | 66 | * global mode: | |
| 67 | - npm installs packages into the install prefix at `$npm_config_prefix/lib/node_modules` and bins to `$npm_config_prefix/bin`. | ||
| 67 | + npm installs packages into the install prefix at `$NPM_CONFIG_PREFIX/lib/node_modules` and bins to `$NPM_CONFIG_PREFIX/bin`. | ||
| 68 | 68 | ||
| 69 | 69 | Local mode is the default. | |
| 70 | 70 | Use `-g` or `--global` on any command to run in global mode instead. | |
@@ -98,8 +98,8 @@ It reads its configuration options from 5 places. | |||
| 98 | 98 | All keys take a value, even if they are booleans (the config parser doesn't know what the options are at the time of parsing). | |
| 99 | 99 | If you do not provide a value (`--key`) then the option is set to boolean `true`. | |
| 100 | 100 | * Environment Variables: | |
| 101 | - Set any config by prefixing the name in an environment variable with `npm_config_`. | ||
| 102 | - For example, `export npm_config_key=val`. | ||
| 101 | + Set any config by prefixing the name in an environment variable with `NPM_CONFIG_`. | ||
| 102 | + For example, `export NPM_CONFIG_KEY=val`. | ||
| 103 | 103 | * User Configs: | |
| 104 | 104 | The file at `$HOME/.npmrc` is an ini-formatted list of configs. | |
| 105 | 105 | If present, it is parsed. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,16 @@ Put keywords in it. | |||
| 65 | 65 | It's an array of strings. | |
| 66 | 66 | This helps people discover your package as it's listed in `npm search`. | |
| 67 | 67 | ||
| 68 | + Example: | ||
| 69 | + | ||
| 70 | + ```json | ||
| 71 | + "keywords": [ | ||
| 72 | + "node", | ||
| 73 | + "javascript", | ||
| 74 | + "npm" | ||
| 75 | + ] | ||
| 76 | + ``` | ||
| 77 | + | ||
| 68 | 78 | ### homepage | |
| 69 | 79 | ||
| 70 | 80 | The URL to the project homepage. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,12 @@ Package descriptors have the following fields: | |||
| 119 | 119 | ||
| 120 | 120 | * bin, license, engines, dependencies, optionalDependencies: fields from `package.json` | |
| 121 | 121 | ||
| 122 | + * os: An array of operating systems this package is compatible with, as specified in `package.json`. This field is included when the package specifies OS restrictions. | ||
| 123 | + | ||
| 124 | + * cpu: An array of CPU architectures this package is compatible with, as specified in `package.json`. This field is included when the package specifies CPU restrictions. | ||
| 125 | + | ||
| 126 | + * funding: Funding information for the package, as specified in `package.json`. This field contains details about how to support the package maintainers. | ||
| 127 | + | ||
| 122 | 128 | #### dependencies | |
| 123 | 129 | ||
| 124 | 130 | Legacy data for supporting versions of npm that use `lockfileVersion: 1`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,8 @@ For details see [this issue](https://github.com/npm/npm/issues/14528). | |||
| 31 | 31 | ||
| 32 | 32 | Notice that you need to use underscores instead of dashes, so `--allow-same-version` would become `npm_config_allow_same_version=true`. | |
| 33 | 33 | ||
| 34 | + **Important:** When defining custom configuration keys in `.npmrc` files, use hyphens instead of underscores (e.g., `custom-key=value`). This ensures they can be overridden by environment variables, since npm automatically converts underscores to hyphens when reading environment variables. Keys with underscores in `.npmrc` files cannot be overridden via environment variables. | ||
| 35 | + | ||
| 34 | 36 | #### npmrc Files | |
| 35 | 37 | ||
| 36 | 38 | The four relevant files are: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,7 @@ These scripts happen in addition to the `pre<event>`, `post<event>`, and | |||
| 43 | 43 | * Runs BEFORE the package is packed, i.e. | |
| 44 | 44 | during `npm publish` and `npm pack` | |
| 45 | 45 | * Runs on local `npm install` without any arguments | |
| 46 | - * Runs AFTER `prepublish`, but BEFORE `prepublishOnly` | ||
| 46 | + * Runs AFTER `prepublishOnly` and `prepack`, but BEFORE `postpack` | ||
| 47 | 47 | * Runs for a package if it's being installed as a link through `npm install <folder>` | |
| 48 | 48 | ||
| 49 | 49 | * NOTE: If a package being installed through git contains a `prepare` script, its `dependencies` and `devDependencies` will be installed, and the prepare script will be run, before the package is packaged and installed. | |
@@ -333,7 +333,7 @@ They just have to be some kind of executable file. | |||
| 333 | 333 | Read through [`package.json`](/configuring-npm/package-json) to see all the things that you can specify and enable by simply describing your package appropriately. | |
| 334 | 334 | In general, this will lead to a more robust and consistent state. | |
| 335 | 335 | * Inspect the env to determine where to put things. | |
| 336 | - For instance, if the `npm_config_binroot` environment variable is set to `/home/user/bin`, then don't try to install executables into `/usr/local/bin`. | ||
| 336 | + For instance, if the `NPM_CONFIG_BINROOT` environment variable is set to `/home/user/bin`, then don't try to install executables into `/usr/local/bin`. | ||
| 337 | 337 | The user probably set it up that way for a reason. | |
| 338 | 338 | * Don't prefix your script commands with "sudo". If root permissions are required for some reason, then it'll fail with that error, and the user will sudo the npm command in question. | |
| 339 | 339 | * Don't use `install`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,6 +86,26 @@ If you want to add a dependency named `abbrev` from the registry as a dependency | |||
| 86 | 86 | npm install abbrev -w a | |
| 87 | 87 | ``` | |
| 88 | 88 | ||
| 89 | + **Adding a workspace as a dependency of another workspace:** | ||
| 90 | + | ||
| 91 | + If you want to add workspace **b** as a dependency of workspace **a**, you can use the workspace protocol in the dependency specifier: | ||
| 92 | + | ||
| 93 | + ``` | ||
| 94 | + npm install b@workspace:* -w a | ||
| 95 | + ``` | ||
| 96 | + | ||
| 97 | + This will add an entry to workspace **a**'s `package.json` like: | ||
| 98 | + | ||
| 99 | + ```json | ||
| 100 | + { | ||
| 101 | + "dependencies": { | ||
| 102 | + "b": "workspace:*" | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + ``` | ||
| 106 | + | ||
| 107 | + The `workspace:` protocol tells npm to link to the local workspace rather than fetching from the registry. The `*` version means it will use whatever version is defined in workspace **b**'s `package.json`. | ||
| 108 | + | ||
| 89 | 109 | Note: other installing commands such as `uninstall`, `ci`, etc will also respect the provided `workspace` configuration. | |
| 90 | 110 | ||
| 91 | 111 | ### Using workspaces | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-access----1163"> | ||
| 144 | + <h1 id="----npm-access----1164"> | ||
| 145 | 145 | <span>npm-access</span> | |
| 146 | - <span class="version">@11.6.3</span> | ||
| 146 | + <span class="version">@11.6.4</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Set access level on published packages</span> | |
| 149 | 149 | </header> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-adduser----1163"> | ||
| 144 | + <h1 id="----npm-adduser----1164"> | ||
| 145 | 145 | <span>npm-adduser</span> | |
| 146 | - <span class="version">@11.6.3</span> | ||
| 146 | + <span class="version">@11.6.4</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Add a registry user account</span> | |
| 149 | 149 | </header> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments