-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module not found: '@vue/server-renderer' error with Vue test utils (Mocha Chai) #1734
Comments
Same problem for me. I use TypeScript instead of babel, though.
|
Temporary workaround is to pin vue-loader-v16 to beta 7 in your package.json, like so:
I use practically the same setup with cucumber-js instead of mocha (using a custom vue-cli plugin) and encountered exactly the same issue. |
@Korijn Woohooo, that did the trick! 🎉 |
You applied the workaround correctly (judging from your package-lock.json). It must be related to your use of typescript then I guess. Sorry, I can't help you with that. |
I updated my comment above. Thank you again. |
Any workaround on this one? I'm getting this issue on new project created with latest vue-cli. I see vue-loader v15.9.5 and vue-loader-v16 v16.0.0-rc.2 in my node_modules for some reason |
This option provides a solution for vuejs#1734 When testing with mocha + mochapack, even though the target environment is `node`, the compiled component is expected to be run with `jsdom` rather than with a Node.js server, so it should still be a client bundle.
See vuejs/vue-cli#6097 Note: the given reproduction project still fails because of another long-standing issue with project names starting with |
but where to set isServerBuild ?!?! |
always give examples to people DUDE |
The first link IS THE EXAMPLE, DUDE. |
Here is a more down to earth example for the rest of us who use less sophisticated webpack config. module.exports = {
chainWebpack: config => {
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.isServerBuild = false
return options
})
}
} |
@Sergej-Popov The |
@sodatea Not saying you are wrong, but that's how documentation suggests doing it. |
Oops. No wonder it's used in so many places! I think we need to update the documentation. |
Just to clarify for anyone coming across this as this is a confusing thread and the info scattered elsewhere on SO and in other vue projects wasn't clear. For a Vue 3 CLI app configured to use typescript and mocha / chai all I had to do was add a vue.config.js file (there wasn't one by default) to the root of my project and have the following in that file:
For good measure I removed my package-lock.json and my node_modules directories and ran |
Version
16.0.0-beta.8
Reproduction link
https://github.com/andyghiuta/vue-loader-server-renderer-issue
Steps to reproduce
npm run test:unit
What is expected?
Tests to complete (fail or pass)
What is actually happening?
Tests fail:
This is a brand new scaffolded app, no extras.
Deps:
The text was updated successfully, but these errors were encountered: