-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS-Check: cannot find module #28233
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
The stack trace looks like #27867. // @ts-check
const { axios } = require('axios') Your project may be different because of other files you have, particularly a
This is with axios 0.18.0 installed. |
Here's the contents of my {
"compilerOptions": {
"target": "ES6",
"lib": ["es5", "es6", "es7"]
}
} However, having tested again with the |
@Andy-MS So i've been testing, and I've found something else which is strange The project is laid out like this:
If i have the Could the issue be related to the fact that there are so many |
@Andy-MS Any update on this issue? |
@NileDaley Does this issue still happen for you? I can try to reproduce it, but it would help me a lot to have the actual project that's failing. If you can share that some way I can sign an NDA if that would help. |
This was a long time ago, and I don't experience the issue anymore as we're now using typescript instead of js + tscheck. As far as I can remember, the issue was caused by having the jsconfig.json file in the wrong folder. I had it at the root of the project, whereas it needed to be further down in the tree. From my example above, it needed to change to
So it actually couldn't find the module because there is no node_modules at the root level where the jsconfig.json was. |
I'm having the same issue on some packages inside node_modules (writing javascript, not typescript). Some of them work just fine, but some throw ts check errors. For example the screenfull package is throwing the 'cannot find module' error. if (isCommonjs) {
module.exports = screenfull;
} else {
window.screenfull = screenfull;
} Using Webpack 4 to import the module. Everything is working fine in the website output. -- Also it looks like jsconfig path-aliases are ignored (here require('modules/prismjs/plugins/keep-markup/prism-keep-markup.js'); This is the jsconfig.json:
Could it be @ts-check doesn't work well while using Webpack imports/requires? |
@sandersn I'm also having this issue, not with I have a feeling it's my lack of experience that's causing this and I'm missing something obvious and/or configured something wrong, anticipated apologies if so 😞 Edit: never mind me, I had |
I encountered this when setting |
Found similar issue when switching to VS Code / JSdoc / @ts-check with JS / ES6 as a lightweight alternative to TypeScript, for type-checking. If I put If I put May be obvious to some, but I don't like the suggestion on the VS Code documentation that you should place the file in e.g. |
TypeScript Version: 3.1.3
Code
Expected behavior:
Axios will be required from './node_modules/axios/index'
Actual behavior:
Error shown is
cannot find module 'axios'
despite axios being installed. Note that this problem is not axios specific, it occurs with any module. However, if I use the following syntax then it is required correctly.Screenshots:
The error:
No error when using path:
TypeScript debug error:
The text was updated successfully, but these errors were encountered: