webpack1~npm run dev失败

2017.01.06

nodejs 6.9使用webpack2+vue2,npm run dev起服务失败。

> vue2@ dev /Users/zhuxu/Documents/playground/vue2-router
> webpack-dev-server --open --inline --hot

/Users/zhuxu/Documents/playground/vue2-router/node_modules/webpack-dev-server/bin/webpack-dev-server.js:385
        throw e;
        ^

TypeError: webpack.validateSchema is not a function
    at new Server (/Users/zhuxu/Documents/playground/vue2-router/node_modules/webpack-dev-server/lib/Server.js:23:33)
    at startDevServer (/Users/zhuxu/Documents/playground/vue2-router/node_modules/webpack-dev-server/bin/webpack-dev-server.js:378:12)
    at /Users/zhuxu/Documents/playground/vue2-router/node_modules/webpack-dev-server/bin/webpack-dev-server.js:324:3
    at /Users/zhuxu/Documents/playground/vue2-router/node_modules/portfinder/lib/portfinder.js:160:14
    at /Users/zhuxu/Documents/playground/vue2-router/node_modules/async/lib/async.js:52:16
    at /Users/zhuxu/Documents/playground/vue2-router/node_modules/async/lib/async.js:269:32
    at /Users/zhuxu/Documents/playground/vue2-router/node_modules/async/lib/async.js:44:16
    at /Users/zhuxu/Documents/playground/vue2-router/node_modules/portfinder/lib/portfinder.js:122:16
    at Server.onListen (/Users/zhuxu/Documents/playground/vue2-router/node_modules/portfinder/lib/portfinder.js:45:7)
    at Server.g (events.js:291:16)

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! vue2@ dev: `webpack-dev-server --open --inline --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue2@ dev script 'webpack-dev-server --open --inline --hot'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vue2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server --open --inline --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vue2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vue2
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

网上查到如下方案

Looks like npm bug, since webpack-dev-server@2.1.0-beta.11
 requires webpack@^2.1.0-beta.26
but npm failed to install it.
The easiest way to avoid the issue without updating too much is to change dependency in package.json to
 "webpack-dev-server": "2.1.0-beta.10",

Instead of something like
 "webpack-dev-server": "^2.1.0-beta.9",

"^" char before version says "compatible with". Removing it sticks to the version exactly.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 每天都有加法的冲动 每天也有减法的念头 在这个过程中 体会到的是 成长比成功重要
    天籁村阅读 1,364评论 0 0
  • 今天要画T恤和紫色蝴蝶结,却让我无从下手,这张是跟着铃铛子老师视频画下来的,不得不承认我前面的胡乱临摹让我...
    金圆迪阅读 1,346评论 0 3
  • 在静好的岁月里 不争不扰 若不是那年任性 怎会 挣脱静好.投身喧嚣 若不是那份偏执 何须 战战兢兢.故作美好 若不...
    Y余小姐阅读 1,598评论 0 0

友情链接更多精彩内容