You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deps/npm/docs/content/configuring-npm/package-lock-json.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
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`.
Copy file name to clipboardExpand all lines: deps/npm/docs/content/using-npm/config.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
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.
Copy file name to clipboardExpand all lines: deps/npm/docs/content/using-npm/scripts.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
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.
Copy file name to clipboardExpand all lines: deps/npm/docs/content/using-npm/workspaces.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
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.
0 commit comments