npm v12 の今後の破壊的変更点について
本文の状態
日本語全文を表示中
詳細モードで約3分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
GitHub Changelog
npm は次期メジャーバージョン v12 で、依存関係のスクリプト実行をデフォルトで無効化するセキュリティ関連の変更を導入する。この変更は 2026 年 7 月のリリースを見込んでおり、現在は警告表示として既存バージョンでも確認可能である。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
次の npm メジャーバージョンである v12 では、npm install にセキュリティ関連のデフォルト変更が導入されます。これらの変更はすべて、現在の npm 11.16.0 以降で警告として利用可能なので、アップグレード前に準備することができます。v12 のリリースは 2026 年 7 月と見込まれています。
各変更は、今日自動的に実行される npm install の動作を、明示的にオプトインする必要がある動作へと転換します:
allowScripts はデフォルトでオフになります:npm install は、プロジェクト内で明示的に許可されない限り、依存関係からの preinstall、install、postinstall スクリプトを実行しなくなります。これにはネイティブな node-gyp ビルド(binding.gyp を持ち、明示的なインストールスクリプトを持たないパッケージも含まれますが、npm がそのために暗黙的な node-gyp リビルドを実行するためブロックされます)も該当します。git、file、link 依存関係からの prepare スクリプトも同様にブロックされます。何がブロックされるかを確認するには、npm approve-scripts --allow-scripts-pending を実行してください。その後、信頼できるパッケージを npm approve-scripts で許可し、残りを npm deny-scripts でブロックします。結果として生成される許可リストは package.json に書き込まれ、コミットする必要があります。インストールルーチンでスクリプトを実行する場合は、npm 11.16.0 以降で警告を確認できます。
--allow-git はデフォルトで none(なし)になります:npm install は、明示的に --allow-git を指定しない限り、Git 依存関係(直接または間接的)を解決しなくなります。これにより、--ignore-scripts を使用していても Git 依存関係の .npmrc が Git 実行ファイルを上書きできるコード実行経路が閉ざされます。この変更は以前に 2026-02-18 に発表されており、npm 11.10.0 以降で利用可能です。
--allow-remote のデフォルト値が none に変更されます:npm install は、--allow-remote 経由で明示的に許可されない限り、https ターバル(直接または転送依存)などのリモート URL から依存関係を解決しなくなります。このフラグは npm 11.15.0 以降で使用可能です。関連する --allow-file および --allow-directory フラグのデフォルト値は v12 では変更されません。
準備方法
npm を 11.16.0 以降にアップグレードし、通常のインストールを実行して警告を確認してください。npm approve-scripts --allow-scripts-pending を実行して、スクリプトを持つパッケージを特定し、信頼できるものを承認し、更新された package.json をコミットします。その後、アップグレードしても実行されるのは承認したスクリプトのみとなり、未承認のものは停止します。詳細は、npm approve-scripts、npm deny-scripts、および allow-scripts 設定(npx およびグローバルインストール用)に関するドキュメントをご覧ください。コミュニティディスカッションでコメントや質問を共有してください。
原文を表示
Our next npm major version, v12, introduces security-related default changes to npm install. All these changes are available behind warnings in npm today on 11.16.0 or newer, so you can prepare before the upgrade. v12 is estimated to release in July 2026.
Each change turns an npm install behavior that runs automatically today into one you explicitly opt into:
allowScripts defaults to off: npm install will no longer execute preinstall, install, or postinstall scripts from dependencies unless they are explicitly allowed in your project. This includes native node-gyp builds (i.e., a package with a binding.gyp and no explicit install script still gets blocked, because npm runs an implicit node-gyp rebuild for it). prepare scripts from git, file, and link dependencies are blocked the same way. To see what would be blocked, run npm approve-scripts --allow-scripts-pending. Then allow the packages you trust with npm approve-scripts and block the rest with npm deny-scripts. The resulting allowlist is written to package.json and should be committed. If your install routine runs scripts, you can observe warnings in npm 11.16.0+.
--allow-git defaults to none: npm install will no longer resolve Git dependencies (direct or transitive) unless explicitly allowed via --allow-git. This closes a code-execution path where a Git dependency’s .npmrc could override the Git executable, even with --ignore-scripts. This change was previously announced on 2026-02-18 and is available in npm 11.10.0+.
--allow-remote defaults to none: npm install will no longer resolve dependencies from remote URLs, such as https tarballs (direct or transitive), unless explicitly allowed via --allow-remote. This flag is available in npm 11.15.0+. The related --allow-file and --allow-directory flags are not changing their defaults in v12.
How to prepare
Upgrade to npm 11.16.0 or later, run your normal install, and review the warnings. Use npm approve-scripts --allow-scripts-pending to see which packages have scripts, approve the ones you trust, and commit the updated package.json. After that, only the scripts you approved keep running once you upgrade. Anything you leave unapproved will stop. More details are available in our docs at npm approve-scripts, npm deny-scripts, and allow-scripts config (for npx and global installs). Please share your comments and questions in our community discussion.
The post Upcoming breaking changes for npm v12 appeared first on The GitHub Blog.
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み