Unable to build when using vue-google-maps: Unexpected token <
See original GitHub issueDescription
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
- Include vue-google-maps in your Gridsome project (refer to quickstart: https://github.com/xkjyeah/vue-google-maps#quickstart-webpack-nuxt)
- 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:
- Created 4 years ago
- Reactions:5
- Comments:7 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, I think I know what goes wrong. Try this in your
gridsome.config.js
file: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).