AI觉醒星球
Awakening is here
Knowledge File / 全球热点解读
2026-06-10 2 浏览 公开

趋势解读:Upcoming breaking changes for npm v12,提升开发者接入体验

趋势解读:Upcoming breaking changes for npm v12,提升开发者接入体验:这条内容属于全球热点,核心焦点是提升开发者接入体验,适合继续追踪它对内容生产、业务执行和工具工作流的直接影响。

SOURCE / 全球热点解读 MIN / 4 ACCESS / 公开 POST / 2026-06-10 04:04:10

原贴

查看原文
作者:Allison 来源站点:github.blog 原贴时间:

原文

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-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. --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. 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 .

中文翻译

我们的下一个 npm 主要版本 v12 对 npm install 引入了与安全相关的默认更改。所有这些更改都在今天的 11.16.0 或更高版本的 npm 警告后面可用,因此您可以在升级之前做好准备。 v12 预计将于 2026 年 7 月发布。每项更改都会将今天自动运行的 npm install 行为转变为您明确选择的行为:allowScripts 默认为关闭:npm install 将不再执行依赖项中的 preinstall 、 install 或 postinstall 脚本,除非您的项目中明确允许它们。这包括本机 Node-gyp 构建(即,带有 Binding.gyp 且没有显式安装脚本的包仍然会被阻止,因为 npm 为其运行隐式 Node-gyp 重建)。来自 git、文件和链接依赖项的准备脚本也会以同样的方式被阻止。要查看将阻止哪些内容,请运行 npmapprove-scripts --allow-scripts-pending 。然后使用 npmapprove-scripts 允许您信任的软件包,并使用 npmdeny-scripts 阻止其余的软件包。生成的允许列表将写入 package.json 并应提交。如果您的安装例程运行脚本,您可以在 npm 11.16.0+ 中观察到警告。 --allow-git 默认为 none :npm install 将不再解析 Git 依赖项(直接或传递),除非通过 --allow-git 明确允许。这会关闭一个代码执行路径,其中 Git 依赖项的 .npmrc 可以覆盖 Git 可执行文件,即使使用 --ignore-scripts 也是如此。此更改之前已于 2026 年 2 月 18 日宣布,并在 npm 11.10.0+ 中提供。 --allow-git 默认为 none :npm install 将不再解析 Git 依赖项(直接或传递),除非通过 --allow-git 明确允许。这会关闭一个代码执行路径,其中 Git 依赖项的 .npmrc 可以覆盖 Git 可执行文件,即使使用 --ignore-scripts 也是如此。此更改之前已于 2026 年 2 月 18 日宣布,并在 npm 11.10.0+ 中提供。 --allow-remote 默认为 none :npm install 将不再解析来自远程 URL 的依赖项,例如 https tarball(直接或传递),除非通过 --allow-remote 明确允许。该标志在 npm 11.15.0+ 中可用。相关的 --allow-file 和 --allow-directory 标志在 v12 中不会更改其默认值。 --allow-remote 默认为 none :npm install 将不再解析来自远程 URL 的依赖项,例如 https tarball(直接或传递),除非通过 --allow-remote 明确允许。该标志在 npm 11.15.0+ 中可用。相关的 --allow-file 和 --allow-directory 标志在 v12 中不会更改其默认值。升级到 npm 11.16.0 或更高版本,运行正常安装,然后查看警告。使用 npmapprove-scripts --allow-scripts-pending 查看哪些包有脚本,批准您信任的包,并提交更新的 package.json 。此后,只有您批准的脚本在升级后才会继续运行。任何未经批准的事情都会停止。更多详细信息可在我们的文档中找到,网址为 npmapprove-scripts 、 npmdeny-scripts 和allow-scriptsconfig(适用于 npx 和全局安装)。请在我们的社区讨论中分享您的意见和问题。

核心信息

趋势解读:Upcoming breaking changes for npm v12,提升开发者接入体验:这条内容属于全球热点,核心焦点是提升开发者接入体验,适合继续追踪它对内容生产、业务执行和工具工作流的直接影响。

  • 趋势解读:Upcoming breaking changes for npm v12,提升开发者接入体验:这条内容属于全球热点,核心焦点是提升开发者接入体验,适合继续追踪它对内容生产、业务执行和工具工作流的直接影响。
  • 原贴提到:Our next npm major version, v12, introduces security-related default cha
  • 来源:github.blog

详细解读

我们的下一个 npm 主要版本 v12 对 npm install 引入了与安全相关的默认更改。所有这些更改都在今天的 11.16.0 或更高版本的 npm 警告后面可用,因此您可以在升级之前做好准备。 v12 预计将于 2026 年 7 月发布。每项更改都会将今天自动运行的 npm install 行为转变为您明确选择的行为:allowScripts 默认为关闭:npm install 将不再执行依赖项中的 preinstall 、 install 或 postinstall 脚本,除非您的项目中明确允许它们。这包括本机 Node-gyp 构建(即,带有 Binding.gyp 且没有显式安装脚本的包仍然会被阻止,因为 npm 为其运行隐式 Node-gyp 重建)。来自 git、文件和链接依赖项的准备脚本也会以同样的方式被阻止。要查看将阻止哪些内容,请运行 npmapprove-scripts --allow-scripts-pending 。然后使用 npmapprove-scripts 允许您信任的软件包,并使用 npmdeny-scripts 阻止其余的软件包。生成的允许列表将写入 package.json 并应提交。如果您的安装例程运行脚本,您可以在 npm 11.16.0+ 中观察到警告。 --allow-git 默认为 none :npm install 将不再解析 Git 依赖项(直接或传递),除非通过 --allow-git 明确允许。这会关闭一个代码执行路径,其中 Git 依赖项的 .npmrc 可以覆盖 Git 可执行文件,即使使用 --ignore-scripts 也是如此。此更改之前已于 2026 年 2 月 18 日宣布,并在 npm 11.10.0+ 中提供。 --allow-git 默认为 none :npm install 将不再解析 Git 依赖项(直接或传递),除非通过 --allow-git 明确允许。这会关闭一个代码执行路径,其中 Git 依赖项的 .npmrc 可以覆盖 Git 可执行文件,即使使用 --ignore-scripts 也是如此。此更改之前已于 2026 年 2 月 18 日宣布,并在 npm 11.10.0+ 中提供。 --allow-remote 默认为 none :npm install 将不再解析来自远程 URL 的依赖项,例如 https tarball(直接或传递),除非通过 --allow-remote 明确允许。该标志在 npm 11.15.0+ 中可用。相关的 --allow-file 和 --allow-directory 标志在 v12 中不会更改其默认值。 --allow-remote 默认为 none :npm install 将不再解析来自远程 URL 的依赖项,例如 https tarball(直接或传递),除非通过 --allow-remote 明确允许。该标志在 npm 11.15.0+ 中可用。相关的 --allow-file 和 --allow-directory 标志在 v12 中不会更改其默认值。升级到 npm 11.16.0 或更高版本,运行正常安装,然后查看警告。使用 npmapprove-scripts --allow-scripts-pending 查看哪些包有脚本,批准您信任的包,并提交更新的 package.json 。此后,只有您批准的脚本在升级后才会继续运行。任何未经批准的事情都会停止。更多详细信息可在我们的文档中找到,网址为 npmapprove-scripts 、 npmdeny-scripts 和allow-scriptsconfig(适用于 npx 和全局安装)。请在我们的社区讨论中分享您的意见和问题。

信息差价值

这条内容的真正价值,不只是“有人发布了一个新功能”,而是它揭示了 github.blog 背后的产品方向、工作流变化或竞争信号。对 OPC 来说,这种信息可以转化成持续追踪的栏目选题。

如果把《趋势解读:Upcoming breaking changes for npm v12,提升开发者接入体验》放到你的内容系统里,它最大的价值在于帮助读者更快看懂“为什么值得关注”,而不是只看到一条碎片化动态。

参考来源

上一篇 IBM CEO:AI不一定导致员工减少 下一篇 Mythos 5 智能体因资源互相杀戮