Component is not processed by Webpack ( Unexpected token < )
See original GitHub issueWhen loaded as the following:
<template>
<pdf v-bind:src="_document" />
</template>
<script>
import pdf from 'vue-pdf';
export default {
components: {
pdf
},
_document: {
data: "..."
}
}
</script>
I get the following error:
[vue-router] Failed to resolve async component default: SyntaxError: Unexpected token <
[vue-router] uncaught error during route navigation:
/Users/betacar/Code/JavaScript/project/node_modules/vue-pdf/src/pdf.vue:1
(function (exports, require, module, __filename, __dirname) { <template>
^
SyntaxError: Unexpected token <
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at r (/Users/betacar/Code/JavaScript/project/node_modules/vue-server-renderer/build.js:5812:16)
at Object.<anonymous> (server-bundle.js:1980:18)
at __webpack_require__ (server-bundle.js:27:30)
at Object.47 (0.server-bundle.js:35:66)
at __webpack_require__ (server-bundle.js:27:30)
at Object.44 (0.server-bundle.js:9:3)
at __webpack_require__ (server-bundle.js:27:30)
Am I missing something?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:39 (10 by maintainers)
Top Results From Across the Web
Webpack and React -- Unexpected token - Stack Overflow
I am new to React and Webpack. I am setting up my first project, when I try to run the webpack-dev-server my code...
Read more >module parse failed: unexpected token (1:0) you may need an ...
Answer. The root cause is that your Typescript rule isn't matching (“currently no loaders are configured to process this file”), so Webpack is...
Read more >SyntaxError Invalid or unexpected token - How to SSR images ...
It will also break on any CSS or other non-reacting elements. That implies you can't reuse any client-side components and re-render them on...
Read more >[Help] Module parse failed: Unexpected token . Babel not ...
Delete node_modules folder and try again, make sure you use latest LTS versions for node and npm. Freddie ...
Read more >How I Fixed The Unexpected Token Error In Jest
Depending upon your setup, you might see the error on the first line of the code file or you might see it when...
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
I had this issue today, using the nuxt/pwa template
nuxt version: 1.4.1 vue-pdf: 3.3.1
For me, this worked: (but I get the
[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render.
)vue-pdf
is delivered without bundle (nodist/
directory), then you need to tell your build system (webpack or any other) to includevue-pdf
in their compilation process and eventually to transpilevue-pdf
.webpack:
webpack-node-externals
, you must addvue-pdf
in thewhitelist: []
\.js
webpack rule does not exclude thenode_modules/vue-pdf
directorynuxt: