[RRFC] Allow suppressing workspace allowScripts warnings for intentional standalone workspace packages

Aperta
#906 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript
Ambito
cli

Direzione di ricerca

Esamina il comportamento degli avvisi introdotto da npm/cli#9360 e la policy allowScripts in npm/rfcs#868. Riproduci la configurazione del workspace descritta nell’issue, quindi definisci una proposta di configurazione con ambito strettamente limitato che mantenga l’avviso per impostazione predefinita e sopprima solo questo avviso del workspace quando viene abilitata esplicitamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Feature Request: Allow suppressing workspace allowScripts warnings for intentional standalone workspace packages
Current Behavior

In an npm workspace, npm warns when a non-root workspace package has a top-level allowScripts field:

npm warn allow-scripts allowScripts in workspace project (/path/to/repo/apps/project) is ignored. Move the field to the project root package.json.

This warning is technically correct for a root workspace install, but it is not always actionable.

In our monorepo, some workspaces are Git submodules and can also be installed, developed, or released as standalone projects. Their package.json files intentionally contain their own allowScripts policy for standalone usage. When those same projects are checked out inside the parent monorepo, npm treats them as workspaces and warns on every root install.

Moving the field to the parent root is not a valid fix because the submodule must remain self-contained.

Expected Behavior

npm should provide a targeted way to suppress this warning when a workspace package intentionally keeps allowScripts for standalone use.

For example, one of:

warn-workspace-allow-scripts=false

or:

allow-scripts-warn-workspaces=false

or another narrowly scoped config name.

This should suppress only the non-root workspace allowScripts warning, without requiring loglevel=error and without hiding unrelated npm warnings.

Why This Matters

loglevel=error is currently the only practical workaround, but it suppresses too much. In CI and local development, teams still want to see peer dependency warnings, deprecations, audit warnings, and other useful npm warnings.

The current warning becomes noisy in monorepos that include standalone packages or Git submodules as workspaces. In that setup, the warning is expected and non-actionable, because the package-local policy is needed outside the parent workspace context.

Steps To Reproduce
  1. Create a root workspace package:
{
  "private": true,
  "workspaces": ["packages/*"]
}
  1. Create packages/example/package.json:
{
  "name": "example",
  "version": "1.0.0",
  "allowScripts": {
    "[email protected]": true
  }
}
  1. Run:
npm install
  1. Observe:
npm warn allow-scripts allowScripts in workspace example (.../packages/example) is ignored. Move the field to the project root package.json.
Proposed Solution

Add a narrowly scoped npm config that disables this specific warning.

Default should remain the current behavior, so users still get warned unless they explicitly opt out.

References

This warning appears to have been introduced as part of npm/cli#9360, which implemented Phase 1 of the allowScripts install-script policy from npm/rfcs#868.

https://github.com/npm/cli/pull/9360
https://github.com/npm/rfcs/pull/868

Lingua principale
JavaScript
Stelle
780
Fork
266
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/rfcs

Tutte le issue di npm/rfcs

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.