Bootstrap installed via npm throws error on error "Error: cannot find jQuery module"

I'm new to node, and npm and express.js are still learning. on the bootstrap website you can use bootstrap with npm install, and I did the same boot using npm install bootstrap --save, did it for jquery too and was needed in app.js

App.js file

var jQuery = require('jquery');
var bootstrap = require('bootstrap');

This has also changed.

global.jQuery = require('jquery');
var bootstrap = require('bootstrap');

var jQuery = require ('jquery'); var bootstrap = require ('bootstrap');

but when I start DEBUG=nodeAangularMySql:* ./bin/www, I get the following errors.

/home/sharif/Sites/node/nodeAangularMySql/node_modules/bootstrap/js/transition.js:59
}(jQuery);
  ^
ReferenceError: jQuery is not defined
    at Object.<anonymous> (/home/sharif/Sites/node/nodeAangularMySql/node_modules/bootstrap/js/transition.js:59:3)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/sharif/Sites/node/nodeAangularMySql/node_modules/bootstrap/dist/js/npm.js:2:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

This is my first time I downloaded and copied bootstrap, in the stylesheets folder in a shared folder or in a Google CDN.

never used this before. I would like to know a little thisn

  • How to use boot using npm install
  • jquery npm
  • .

?

+4
2

CDN hbs html, CDN .

, node, CDN , .

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet"/>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
0

:

var jQuery = require('jquery');
window.$ = window.jQuery = jQuery;
var bootstrap = require('bootstrap');

, linter like eslint, .

, $ jQuery , bootstrap. , JS jQuery, , $ jQuery , . . window.jQuery, .

0

All Articles