vue-google-autocomplete和nuxt 2.1.0-无法nuxt生成它-加载页面时出错

时间:2018-10-05 14:20:30

标签: vue.js vue-component nuxt.js

加载包含vue-google-autocomplete模块的页面时遇到问题。问题如下所示

✖ error /.../node_modules/vue-google-autocomplete/src/VueGoogleAutocomplete.vue:1
  (function (exports, require, module, __filename, __dirname) { <template>
  ^

  SyntaxError: Unexpected token <
  at new Script (vm.js:74:7)
  at createScript (vm.js:246:10)
  at Object.runInThisContext (vm.js:298:10)
  at Module._compile (internal/modules/cjs/loader.js:670:28)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
  at Module.load (internal/modules/cjs/loader.js:612:32)
  at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
  at Function.Module._load (internal/modules/cjs/loader.js:543:3)
  at Module.require (internal/modules/cjs/loader.js:650:17)
  at require (internal/modules/cjs/helpers.js:20:18)
  at r (/Users/dariorusignuolo/Desktop/phpstorm/jukemotion-booking/jukemotion-booking-client/node_modules/nuxt/node_modules/vue-server-renderer/build.js:8341:16)
  at Object.vue-google-autocomplete (server-bundle.js:8677:18)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./components/form/j-search.vue?vue&type=script&lang=js& (components/form/j-search.vue?cfb9:1:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Module../components/form/j-search.vue?vue&type=script&lang=js& (components/form/j-search.vue?00ca:1:0)

版本为1.1.0(最新),nuxt版本为2.1.0,而节点版本为10.4.1

即使启动nuxt generate命令,我也要面对确切的问题。

还尝试通过

将此模块的负载放置在插件中来全局加载

Vue.component('vue-google-autocomplete', VueGoogleAutocomplete);

没有任何运气。

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

您需要进行运输。参见nuxt docs

  build: {
    ...
    transpile: ['vue-google-autocomplete']
  }