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(这是一个指向_bootstrap@5.1.3@bootstrap的快捷方式)
│ ├─dist
│ │ ├─css
│ │ └─js
│ ├─js
│ │ ├─dist
│ │ │ └─dom
│ │ └─src
│ │ ├─dom
│ │ └─util
│ └─scss
│ ├─forms
│ ├─helpers
│ ├─mixins
│ ├─utilities
│ └─vendor
└─_bootstrap@5.1.3@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\_bootstrap@5.1.3@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
│ (省略号……)