为什么 npx 每次都安装 webpack? [英] Why does npx install webpack every time?

查看:46
本文介绍了为什么 npx 每次都安装 webpack?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与 webpack 捆绑在一起的 JavaScript 应用程序.根据文档,我正在使用此命令开始捆绑:

I have a JavaScript app I'm bundling with webpack. Per the docs, I'm using this command to start bundling:

npx webpack

每次我得到这个输出:

npx: installed 1 in 2.775s

我已验证 webpack 命令存在于我的 ./node_modules/.bin 目录中, npx 正在查找该目录.谁能想到为什么每次都下载 webpack?完成此步骤最多可能需要 7 秒,这会减慢我的构建速度.

I've verified that the webpack command exists in my ./node_modules/.bin directory where npx is looking. Can anyone think of why it's downloading webpack every time? It can take up to 7 seconds to complete this step, which is slowing down my builds.

推荐答案

npx 不会重用以前安装的包,而是在您每次运行它时拉下该包的依赖项.

npx doesn't reuse previously installed packages, instead it pulls down that package's dependencies every time that you run it.

这篇关于为什么 npx 每次都安装 webpack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆