最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - npm install minified version only - Stack Overflow

programmeradmin0浏览0评论

I just installed Node with npm to use it for frontend dependency management. I know there is also bower but why would I need another package manager that is built on top of another?

When installing a package, npm seems to always load the full source of the js library into the node_modules directory. Just as it's downloading the complete github repository.

How do I install only the minifed (distribution) version of a javascript lib with npm?

I just installed Node with npm to use it for frontend dependency management. I know there is also bower but why would I need another package manager that is built on top of another?

When installing a package, npm seems to always load the full source of the js library into the node_modules directory. Just as it's downloading the complete github repository.

How do I install only the minifed (distribution) version of a javascript lib with npm?

Share Improve this question edited Feb 2, 2023 at 7:08 Mayank Kumar Chaudhari 18.5k13 gold badges67 silver badges151 bronze badges asked Aug 22, 2014 at 12:33 Andreas NeumannAndreas Neumann 3741 gold badge3 silver badges12 bronze badges 2
  • programmers.stackexchange.com/q/224828/105673. I don't know about npm but bower comes with minified version of packages. – Rahil Wazir Commented Aug 22, 2014 at 12:39
  • The difference between npm and bower is mostly in the available repositories. npm is normally used for fetching backend modules (as nodejs normally runs as backend), while bower has repositories for frontend javascript libraries. Only getting the minified version isn't directly possible with npm AFAIK. For bower, there is a feature request for the described behavior. Or you could try with ignore all other file extensions than .min.js inside your bower.json. – ConcurrentHashMap Commented Aug 22, 2014 at 12:40
Add a comment  | 

1 Answer 1

Reset to default 14

There is no standard way to ask npm to get the minified version of a library. Some developers will produce packages that contain both minified and unminified versions (that's what I've done for one of my projects, which is web-only but can be installed through npm) or will create a package that contains an unminified version and another package that contains the minified version. This is done on a case by case basis, varies from package to package, and has to be determined by looking at a project's documentation.

If a developer has not cared to provide a minified code base through npm then you'll have to perform the minification yourself or get the "official" minified code through some other means.

发布评论

评论列表(0)

  1. 暂无评论