1. 程式人生 > 其它 >NPM安裝Bootstrap VS. Bower安裝Bootstrap

NPM安裝Bootstrap VS. Bower安裝Bootstrap

NPM是Node.js的包管理工具,而Bower則是一個前端包管理工具。

根目錄下只有一個index.html

NPM安裝Bootstrap

執行指令:

$ cnpm install bootstrap-
√ Installed 1 packages
√ Linked 1 latest versions
√ Run 0 scripts
peerDependencies WARNING bootstrap@latest requires a peer of @popperjs/core@^2.10.2 but none was installed
√ All packages installed (
1 packages installed from npm registry, used 674ms(network 671ms), speed 21.77KB/s, json 1(14.6KB), tarball 0B)

結果:

D:.
└─node_modules
├─bootstrap(這是一個指向[email protected]@bootstrap的快捷方式)
│ ├─dist
│ │ ├─css
│ │ └─js
│ ├─js
│ │ ├─dist
│ │ │ └─dom
│ │ └─src
│ │ ├─dom
│ │ └─util
│ └─scss
│ ├─forms
│ ├─helpers
│ ├─mixins
│ ├─utilities
│ └─vendor
└─[email protected]@bootstrap
├─dist(直接下載編譯版本,得到的就是該檔案)


│ ├─css
│ └─js
├─js
│ ├─dist
│ │ └─dom
│ └─src
│ ├─dom
│ └─util
└─scss
├─forms
├─helpers
├─mixins
├─utilities
└─vendor

Bower安裝Bootstrap

https://www.npmjs.com/package/bower

清空資料夾,只留一個index.html

在git bash中執行指令bower init:

$ bower init
bower ENOINT        Register requires an interactive shell

Additional error details:
Note that you can manually force an interactive shell with --config.interactive

切換到windows命令列下執行bower init指令,執行成功。再執行bower install bootstrap:

D:\Electron\bootstrap_test>bower install bootstrap
bower retry         Request to https://registry.bower.io/packages/bootstrap failed with ETIMEDOUT, retrying in 1.2s
bower retry         Request to https://registry.bower.io/packages/bootstrap failed with ETIMEDOUT, retrying in 3.2s

執行失敗,改為執行bower install bootstrap --save:

D:\Electron\bootstrap_test>bower install bootstrap --save
bower ENOGIT        git is not installed or not in the PATH

因為不想重灌git bash,於是放棄了用bower安裝bootstrap:

npm uninstall -g bower

直接下載已編譯好的Bootstrap

內容和node_modules\[email protected]@bootstrap\dist一致:

D:.
│ bootstrap-5.1.3-dist.zip
└─bootstrap-5.1.3-dist
├─css
│ bootstrap-grid.css
│ bootstrap-grid.css.map
│ bootstrap-grid.min.css
│ bootstrap-grid.min.css.map
│ (省略號……)

└─js
│bootstrap.bundle.js
│bootstrap.bundle.js.map
│ (省略號……)