bower在初始化,默认是将bower_components文件夹放到项目的根目录下,若是public/index.html如何配置bower_components下的js或者css类库呢?只需要将bower_components配置为项目的静态目录,

APP.js文件内容增加内容:

  app.use(express.static(__dirname+'/bower_components'));

 

 

根据项目的需要有时候,我们不想把bower_components文件夹放到项目的根目录下,假设我们想把bower_components文件夹放到public下面,具体操作见下面步骤:

 

  1. 创建Bower配置文件【.bowerrc】,这个文件是作为bower的配置文件,默认情况的话,可以不存在,若是更改bower_components位置需要更改此文件中的内容。
mkdir public/bower_components
vim .bowerrc

 

.bowerrc文件内容如下:

{
"directory":"public/bower_components"
}

 

2、安装bootstrap,angular,若是采用root用户,则需要使用--allow-root

bower install --save --allow-root angular
bower install --save --allow-root bootstrap

 

相关文章:

  • 2021-08-21
  • 2021-06-05
  • 2022-01-07
  • 2021-12-27
  • 2021-11-30
  • 2021-06-15
  • 2021-07-02
猜你喜欢
  • 2021-07-10
  • 2021-07-26
  • 2021-12-22
  • 2022-12-23
  • 2022-01-18
  • 2022-03-04
  • 2021-11-03
相关资源
相似解决方案