简体   繁体   English

在客户端要求(节点模块给出了dep错误)

[英]require on client side (node module gives a dep error)

I'm trying to use browserify to bundle my js into a file and be able to use require on the client side. 我正在尝试使用browserify将我的js捆绑到一个文件中,并能够在客户端使用require。

But everytime I run browserify or watch on my app.js I get an error from i18next module. 但是每次我运行browserify或在app.js上观看时,我都会从i18next模块收到错误消息。

Error: Cannot find module 'jquery' from '/home/js/testapp/node_modules/i18next/lib/dep'

I've checked i18next and it doesn't need jquery (if it's not available) (no errors are given running the server). 我已经检查过i18next,它不需要jquery(如果它不可用)(运行服务器时没有错误)。

I've tried installing jquery, that problem disappears but other emerges: 我尝试安装jquery,该问题消失了,但其他问题又出现了:

/home/js/testapp/node_modules/i18next/lib/dep/i18next.js:1245
        $.fn.i18n = function (options) {
                  ^
TypeError: Cannot set property 'i18n' of undefined

What am I missing here? 我在这里想念什么?

Thank you 谢谢

It seems it's needed to disable jQuery. 似乎需要禁用jQuery。

Added a config to i18n init (in docs: http://i18next.com/pages/doc_jquery.html ) 在i18n init中添加了一个配置(在文档中: http : //i18next.com/pages/doc_jquery.html

setJqueryExt: false

Now I have this config and no errors 现在我有了这个配置,没有错误

app.use(i18n.handle);

i18n.init({
    cookieName: 'lang',
    fallbackLng: 'en',
    debug: 'true',
    setJqueryExt: false
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM