question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to build when using vue-google-maps: Unexpected token <

See original GitHub issue

Description

I’ve included vue-google-maps in my project and it works perfectly in dev. However, when I try to build my project I receive the following error: SyntaxError: Unexpected token < ...

I notice that Nuxt users are having similar issues - but they seem to have a solution (e.g. https://github.com/xkjyeah/vue-google-maps/issues/537#issuecomment-449900348). Is there something similar we can do in Gridsome?

Steps to reproduce

  1. Include vue-google-maps in your Gridsome project (refer to quickstart: https://github.com/xkjyeah/vue-google-maps#quickstart-webpack-nuxt)
  2. Attempt to build your project (gridsome build)

Expected result

The project should build.

Actual result

A build error is thrown: SyntaxError: Unexpected token <. The file it is complaining about is /path/to/node_modules/vue2-google-maps/dist/components/infoWindow.vue.

Environment


Libs:
- gridsome version: v0.5.7
- @gridsome/cli version: v0.0.9
 
Tooling:
- Node version: v11.14.0
- Platform:  Mac

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
hjvedvikcommented, May 23, 2019

Yes, I think I know what goes wrong. Try this in your gridsome.config.js file:

module.exports = {
  chainWebpack (config, { isServer }) {
    if (isServer) {
      config.externals([/^(vue|vue-router|vue-meta)$/])
    }
  }
}
0reactions
Kainkainkaincommented, Mar 3, 2020

Ok module.exports = { chainWebpack (config, { isServer }) { if (isServer) { config.externals([/^(vue|vue-router|vue-meta)$/]) } } }

Now does work for me. The error I was getting was from my own function which was testing wether referencing an objects.childrens.children exist before using them, and turns out whatever that was doing was throwing exceptions. So my convoluted function was the issue, and rewriting using try catch worked.

TIL more javascript basics: Try, Catch(e).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt: Unexpected token < - Stack Overflow
When I Uncomment the 3 lines with Googlemap in them I get the error in the screenshot . The Googlemap component is: <template>...
Read more >
Module parse failed: Unexpected token (238:16) You may ...
Coding example for the question Module parse failed: Unexpected token (238:16) You may need an appropriate loader to handle this file type-Vue.js.
Read more >
Mousai | Quasar Framework Community
hey guys, I have been receiving an when I try use the quasar build command. The error message is. ERROR in js/vendor.js from...
Read more >
Cant build my vuejs app on production but can locally ... - Reddit
Cant build my vuejs app on production but can locally, SyntaxError: Unexpected token { · Locally it builds fine on Mac · On...
Read more >
vue-google-maps - Bountysource
Created 5 years ago in xkjyeah/vue-google-maps with 20 comments. ... [vue-router] Failed to resolve async component default: SyntaxError: Unexpected token ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found