关于javascript:jQuery未在bootstrap模块中定义

jQuery not define in bootstrap module

我想对我的网站使用引导程序(与node.js一起使用)。 但是我有以下错误:

/var/www/node_modules/bootstrap/js/transition.js:59
}(jQuery);
^
ReferenceError: jQuery is not defined
at Object. (/var/www/node_modules/bootstrap/js/transition.js:59:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/var/www/node_modules/bootstrap/dist/js/npm.js:2:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

我试图做一个

1
var bootstrap = require('bootstrap');

在我的主节点上。

我使用npm(文件夹中的npm install bootstrap)安装了引导程序。 我也尝试以相同的方式安装jquery并添加var jQuery= require('jquery');,但是它不起作用。 您知道什么地方可能出问题吗? 我正在启动node.js,我可能会错过一些东西

然后我在HTML网页中使用来引用引导程序
`


要将jquery插件与npm / node一起使用,您需要先设置全局jQuery变量,然后再要求使用插件[在这种情况下为bootstrap]:

1
2
global.jQuery = require('jquery');
require('bootstrap');

此npm博客文章中的更多详细信息