nodejs express+bootstrap搭建網站

  • nodejs安裝

下載地址:http://nodejs.cn/download/

  • 環境變量配置

添加環境變量:NODE_PATH=D:\tool\nodejs

在nodejs安裝目錄新增如下兩個目錄:node_cache  node_global

打開命令行執行如下命令:

npm set cache = "D:\\tool\\nodejs\\node_cache"

npm set prefix = "D:\\tool\\nodejs\\node_global"

修改PATH:

PATH=%NODE_PATH%;%NODE_PATH%\node_modules;%NODE_PATH%\node_global;

  •  全局安裝express及生成器

npm install -g express

npm install -g express-generator

  • 創建項目

express website -e

  •  啓動項目

npm start

  •  訪問項目

http://127.0.0.1:3000/

  •  添加bower 管理引入的第三方資源包

npm install -g bower

bower init

默認輸入 最後會生成bower.json文件

{
  "name": "website",
  "description": "",
  "main": "",
  "authors": [
    "xxxx"
  ],
  "license": "MIT",
  "homepage": "xxxx",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap": "^4.2.1",
    "jquery": "^3.3.1"
  }
}
 

  • 創建.bowerrc文件

{
    "directory":"public/lib"
}

  • 執行bower install

下載包會自動放到public/lib目錄下

bower install boostrap --save

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章