vue-cli加载器不能使用默认的init for webpack-simple

时间:2017-03-23 02:14:51

标签: node.js webpack vue.js vuejs2 webpack-dev-server

我正在学习Vue.JS.我安装了cli并创建了一个项目:

$ npm install -g vue-cli
$ vue init webpack-simple vue-example
$ cd vue-example
$ npm install
$ npm run dev  # this is where problem starts!

我收到此错误消息:

> vue-example@1.0.0 dev /Users/me/Code/vue/vue-example
> cross-env NODE_ENV=development webpack-dev-server --open --hot

Project is running at http://localhost:8080/
webpack output is served from /dist/
404s will fallback to /index.html
loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: adf2dedbe76c7658d182
Version: webpack 2.3.1
Time: 7592ms
                                    Asset     Size  Chunks                    Chunk Names
logo.png?82b9c7a5a3f405032b1db71a25f67021  6.85 kB          [emitted]
                                 build.js  1.59 MB       0  [emitted]  [big]  main
chunk    {0} build.js (main) 565 kB [entry] [rendered]
   [22] ./~/vue/dist/vue.esm.js 244 kB {0} [built]
   [38] (webpack)/hot/emitter.js 77 bytes {0} [built]
   [39] ./src/main.js 134 bytes {0} [built]
   [40] (webpack)-dev-server/client?http://localhost:8080 5.44 kB {0} [built]
   [41] (webpack)/hot/dev-server.js 1.57 kB {0} [built]
   [42] ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue 188 bytes {0} [built]
   [44] ./src/App.vue 1.59 kB {0} [built]
   [50] (webpack)-dev-server/client/overlay.js 3.6 kB {0} [built]
   [51] (webpack)-dev-server/client/socket.js 856 bytes {0} [built]
   [56] (webpack)-dev-server/~/sockjs-client/lib/entry.js 244 bytes {0} [built]
   [87] (webpack)-dev-server/~/strip-ansi/index.js 161 bytes {0} [built]
   [88] (webpack)-dev-server/~/strip-ansi/~/ansi-regex/index.js 135 bytes {0} [built]
   [90] (webpack)/hot/log-apply-result.js 1.02 kB {0} [built]
   [96] (webpack)/~/node-libs-browser/~/url/url.js 23.3 kB {0} [built]
   [98] multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js 52 bytes {0} [built]
     + 84 hidden modules

ERROR in ./~/css-loader?sourceMap!./~/vue-loader/lib/style-compiler?{"id":"data-v-32781a4c","scoped":false,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue
Module build failed: SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at loadLoader (/Users/me/Code/vue/vue-example/node_modules/webpack/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/Users/me/Code/vue/vue-example/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/Users/me/Code/vue/vue-example/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
 @ ./~/vue-loader/~/vue-style-loader!./~/css-loader?sourceMap!./~/vue-loader/lib/style-compiler?{"id":"data-v-32781a4c","scoped":false,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-272 13:3-17:5 14:22-280
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

我用vue-cli版本2.8.1(最新版本)和较早版本(2.5.0版本)尝试了这一点但没有运气。

任何人都知道如何解决这个问题?似乎默认值应该开箱即用......

我对Vue / webpack都很陌生,所以对我很轻松。

2 个答案:

答案 0 :(得分:1)

您的节点是哪个版本。 我的是v7.1.0

您可能需要

npm cache clean
npm update -g

答案 1 :(得分:1)

我解决这个问题的方法是:

我使用的是Windows 10。