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.

vue-template-compiler throws with v3.0.0-alpha.4

See original GitHub issue

Version

3.0.0-alpha.4

Reproduction link

https://github.com/cexbrayat/vtc-repro

Steps to reproduce

This is a simple app created with the CLI, using the vue-next and the TS plugins:

npx @vue/cli create vtc-repro --inlinePreset '{"plugins": {"@vue/cli-plugin-typescript": {"classComponent": false},"vue-cli-plugin-vue-next": {}}}'

The first commit sets the version to Vue 3.0.0-alpha.3 and, after fixing the component created, running yarn build succeeds.

The second commit bumps Vue to 3.0.0-alpha.4. When running yarn build, the command now throws:

⠹  Building for production...

 ERROR  Failed to compile with 1 errors                                                                                              14:30:17

 error  in [internal]

INTERNAL ERROR(undefined,undefined) When you use `vue` option, make sure to install `vue-template-compiler`.
stack trace:
Error: When you use `vue` option, make sure to install `vue-template-compiler`.
    at Function.resolveScriptBlock (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/fork-ts-checker-webpack-plugin/lib/VueProgram.js:194:19)
    at Object.host.getSourceFile (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/fork-ts-checker-webpack-plugin/lib/VueProgram.js:106:45)
    at findSourceFile (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90581:29)
    at processImportedModules (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90869:25)
    at findSourceFile (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90634:17)
    at /Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90480:85
    at getSourceFileFromReferenceWorker (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90447:34)
    at processSourceFile (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90480:13)
    at processRootFile (/Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:90310:13)
    at /Users/ced-pro/Code/test/vue-cli-tests/vtc-repro/node_modules/typescript/lib/typescript.js:89326:60

After spending some time investigating the issue, I think I’ve found the root cause. vue-template-compiler starts by checking that the Vue version is the correct one. So when using with Vue 3.0.0-alpha.4, we do have this error thrown.

Why is there no error with Vue 3.0.0-alpha.3? Because this line fails when trying to retrieve Vue version with ReferenceError: document is not defined. So the version returned is undefined and the check is OK.

Now that the document is not defined error has been fixed in alpha.4, the check retreives the proper version and fails.

Other info

Quoting @yyx990803 in https://github.com/vuejs/vue-next/issues/670#issuecomment-579785869:

I think this is an issue that should be fixed in vue-cli-plugin-vue-next by not including vue-template-compiler (which is for 2.x only)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
cexbrayatcommented, Jan 29, 2020

Yeah I was trying to dig into it myself, but it looks like it’s not enough to unistall it indeed …

In the meantime, I’m using an ugly workaround, that disables the check in the installed vue-template-compiler. It allows to keep using with Vue 3 with the CLI. As it might be useful to others, here it is:

"postinstall": "FILE=./node_modules/vue-template-compiler/index.js; sed \"s/var vueVersion = .*/var vueVersion = undefined/\" $FILE > $FILE.tmp && mv $FILE.tmp $FILE",
0reactions
cexbrayatcommented, Feb 9, 2020

Hmm it might not be enough as I realize the API is maybe not the same… fork-ts-checker-webpack-plugin tries to call parseComponent and it does not exist in @vue/compiler-sfc, right @yyx990803 ?

So a better alternative is maybe to disable fork-ts-checker-webpack-plugin if the project is using @vue/compiler-sfc. I submitted an other PR doing that https://github.com/vuejs/vue-cli/pull/5172

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-template-compiler throws with v3.0.0-alpha.4 #670 - GitHub
vue -template-compiler throws with v3.0.0-alpha.4 #670 ... This is a simple app created with the CLI, using the vue-next and the TS plugins:....
Read more >
Vuejs 3 webpack : Problem with vue-template-compiler
To make vue 3 work fine with webpack without using vite or vue cli follow these steps : init the package.json like :....
Read more >
Vue 2.7 alpha released : r/vuejs - Reddit
npm install vue-template-compiler@2.7.0-alpha.4 ... When I was asked to throw together a demo app at work last month, I went with Buefy and ......
Read more >
vue-template-compile errors in console - Laracasts
Hello! Can somebody explain that in my Laravel/vue/vuetify application in console I got a lot of errors like: Copy Code ERROR in ....
Read more >
vue-template-compiler | Yarn - Package Manager
This package can be used to pre-compile Vue 2.0 templates into render functions to avoid runtime-compilation overhead and CSP restrictions.
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