在客户端使用 npm 包 [英] Use npm package on client side

查看:58
本文介绍了在客户端使用 npm 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在客户端使用 npm 包?例如,我想使用 dateformat(https://www.npmjs.com/package/dateformat) 包在我的客户端 javascript 文件中

is there a way I can use an npm package on the client side? For example, I want to use the dateformat(https://www.npmjs.com/package/dateformat) package in my client side javascript file

推荐答案

如果你想在客户端使用 npm 你可以考虑使用 browserify 就是为此目的而设计的.节点模块系统与浏览器不兼容,因此 browserify 将 javascript 转换为可以工作的内容.因此得名:browserify.

If you want to use npm on the client you may consider using browserify which is designed for that purpose. The node module system is not compatible with browsers so browserify transpiles the javascript into something that will work. Hence the name : browserify.

这篇关于在客户端使用 npm 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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