-
Notifications
You must be signed in to change notification settings - Fork 157
Vue 3: ERROR: Unable to load the module "typescript". Using "ts-jest" requires this package to be installed. #285
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
Comments
I’m lost. I somehow managed to get rid of this error, but I don’t know what I did. :( I do recall that in-between debugging attempts, I went for a hail-marry |
@kleinfreund Did you manage to figure out the root cause of this issue? I did remove |
@jobegrabber Unfortunately no. In fact, the error resurfaced and I could only get it to work by re-installed typescript. I’ll clean up my reproduction branch and re-open this ticket. |
@kleinfreund Thanks for responding! Looks like |
I don't think #284 is the actual root cause of this. I could be wrong We should remove this dependency somehow, people should not need to install TS if they are not using it. Somewhere there must be a line that does Line 105 in 3706e5d
The way I'd debug this is make a new project without TS, go into I can try looking into this soon. |
This issue is fixed by #302 |
Thanks @boboldehampsink, left a command, keen to get this one out in the wild. |
Is this still an issue? There is an outstanding PR (#302) however when I pull the example repo here, checkout said branch, it works fine out of the box - no errors. I also did |
Edit, I reproduced it. |
@boboldehampsink and @kleinfreund thanks for your patience/help. There is a PR (#302) which works, but requires the user to specify Please review and let me know what you think. I have tested this with the repo above and it worked. |
@lmiller1990 My bad. I must’ve updated my branch after including the typescript package for testing purposes which acts as a workaround. I removed the dependency again so that the reproduction steps work again. I looked at #307 and its changes do make sense to me. 👍 |
This was fixed in #307 and released in [email protected] so I’m closing this issue. |
Issue
I’m playing around with migrating a package to Vue 3 and upgraded a couple of its dependencies including vue-jest to v5.0.0-alpha.5. When running a small test for a JavaScript file which is importing a Vue single file component, I receive the following error from vue-jest:
Full error
It seems that some part of the code is requiring the ts-jest package which I don’t have installed because my package is not using TypeScript.It seems that some part of the code is requiring the typescript via the ts-jest package which is installed as part of the vue-jest package. However, my project doesn’t use TypeScript at all. I suspect the issue starts happening in https://github.com/vuejs/vue-jest/blob/next/lib/process.js (in particular around https://github.com/vuejs/vue-jest/blob/next/lib/process.js#L63-L72). Logging{ tsconfig }
after the line containingconst tsconfig = getTsJestConfig(config)
does not log anything. The utils function for retrieving the jest configuration for TypeScript in https://github.com/vuejs/vue-jest/blob/next/lib/utils.js#L69 seems to be returning aconfigSet
variable missing the properties that being used on the next line.Reproduction
(This isn’t exactly a minimal reproduction case, but I believe the issue is largely independent from how my package is structured or written.)
Clone package.
Enter package.
Check out
migrate-to-vue-version-3
branch.Install dependencies
Run the test for the index.js file.
(Optional) Install typescript and re-run the test in step 5 to see the issue fixed.
Notes
npm install --save-dev typescript
) and replacingimport Vue from 'vue'
withimport * as Vue from 'vue'
(for some reason,Vue
evaluates toundefined
otherwise), the scriptnpm test -- ./src/index.test.js
passes with expected warnings.collectCoverage
andcollectCoverageFrom
settings), the scriptnpm test -- ./src/index.test.js
passes with expected warnings.The text was updated successfully, but these errors were encountered: