我已经使用 Gulp 设置了 browserify。
当我需要 jQuery 时,一切正常:
var $ = require('jquery');
当我尝试要求 jquery 加载模板模块时
var loadTemplate = require('jquery.loadtemplate')
我收到错误
module "jquery.loadtemplate " not found
我像这样使用npm
安装了loadtemplate
npm install --save jquery.loadtemplate
最佳答案
我认为 jquery.loadtemplate 模块的 package.json 中有错误。它应该在某处定义插件的来源,但它丢失了。在其他模块中,源在“main”属性中定义。它应该说类似
“main”:“jquery-loadTemplate/jquery.loadTemplate-1.5.0.js”,
取决于脚本文件的位置。您可以手动更改它,但下次更新/重新安装 npm 包时它将被删除。
关于javascript - 如何使用 browserify 请求 jQuery.loadTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30467628/