How do I load bootstrap using npm?

后端 未结 7 441
无人共我
无人共我 2021-02-01 15:35

I have a npm project that uses jquery.

var $ = require(\'jquery\');

I also have an index html file that references bootstrap.

  • 7条回答
    •  佛祖请我去吃肉
      2021-02-01 16:09

      If you have some trouble to use require('jquery'), there is a more simple way to do it. Just redirect node modules folders (without using any require()).

      app.use('/js', express.static(__dirname + '/node_modules/bootstrap/dist/js')); // redirect bootstrap JS
      app.use('/js', express.static(__dirname + '/node_modules/jquery/dist')); // redirect JS jQuery
      app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css')); // redirect CSS bootstrap
      

      And on your views, just use simply :

      
      
      
      

    提交回复
    热议问题