搜尋

首頁  >  問答  >  主體

javascript - webpack-dev-server不是內部指令,經過scripts配置後可以為什麼?

webpack-dev-server不是內部指令,然後設定package.json的scipt後
npm run server就可以啟動伺服器這是為什麼?

scripts "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    **"server":"webpack-dev-server"**
  },

下面是我package.json的設定

{
  "name": "demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "server":"webpack-dev-server"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-loader": "^6.4.1",
    "css-loader": "^0.28.0",
    "style-loader": "^0.16.1",
    "url-loader": "^0.5.8",
    "webpack": "^2.3.3",
    "webpack-dev-server": "^2.4.2"
  }
}
怪我咯怪我咯2747 天前511

全部回覆(3)我來回復

  • 为情所困

    为情所困2017-05-19 10:44:43

    可以這麼理解,npm run命令会开启一个新的shell,默认把node_modules/.bin添加到环境变量$PATH
    所以你npm run运行的webpack-dev-server来自当前项目的node_modules/.bin目錄下

    回覆
    0
  • 迷茫

    迷茫2017-05-19 10:44:43

    你打過這個webpack-dev-server套件啊 所有有個指令

    回覆
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:44:43

    那我該怎麼設定才能直接使用webpack-dev-server也啟動作用

    回覆
    0
  • 取消回覆