搜索

首页  >  问答  >  正文

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 天前512

全部回复(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
  • 取消回复