From @mogarick on February 11, 2018 15:46
Issue Type
Bug
Description
I have a JS project that depends on mobx and other libs that include its own type definitions bundled and properly declared in its package.json file under the typings key. I added the checkJs: true in my jsconfig.json file but vscode is having problems to recognize mobx type defs because I'm getting the next error when importing any mobx component into my project files:
[js] Cannot find module 'mobx'.
I'm using mobx version 3.4.1 and its package.json file has the proper typings property with the following values:
"typings": "lib/mobx.d.ts"
yet vscode is not recognising it.
I found a SO question that describes the same problem but for a TS project. I followed the ugly workaround by renaming mobx.d.ts to index.d.ts and moving the file to the root lib directory (/node_modules/mobx/index.d.ts), fixing the types paths accordingly and changing the typings property to "typings": "./index.d.ts" but the error remains.
I also have react as dependency and I added the @types/react as dev dependency and in this case vscode does recognises the type defs because they are in the npm_modules/@types directory
So it appears vscode is not processing the package.json typings property but only the ones under node_modules/@types.
It's important to notice the the problem is not related to extensions added. It occurs with a clean vscode version. I uninstalled vscode, deleted all extensions, then re installed it and yet the problem was still there.
It's also important to notice that is not only mobx. I have other dependencies with its type defs bundled and properly declared in its package.json file and I get the same error message for them.
VS Code Info
VS Code version: Code 1.20.0 (c63189deaa8e620f650cc28792b8f5f3363f2c5b, 2018-02-07T17:02:34.244Z)
OS version: Darwin x64 15.6.0
System Info
| Item |
Value |
| CPUs |
Intel(R) Core(TM)2 Duo CPU P8800 @ 2.66GHz (2 x 2660) |
| Load (avg) |
2, 2, 2 |
| Memory (System) |
8.00GB (0.27GB free) |
| Process Argv |
/Applications/Visual Studio Code.app/Contents/MacOS/Electron |
| Screen Reader |
no |
| VM |
0% |
Extensions (9)
| Extension |
Author (truncated) |
Version |
| material-icon-theme |
PKi |
3.2.2 |
| npm-intellisense |
chr |
1.3.0 |
| gitlens |
eam |
8.0.0 |
| prettier-vscode |
esb |
1.1.3 |
| mssql |
ms- |
1.3.0 |
| debugger-for-chrome |
msj |
4.1.0 |
| java |
red |
0.18.1 |
| vscode-java-debug |
vsc |
0.6.0 |
| vscode-java-pack |
vsc |
0.2.0 |
Copied from original issue: microsoft/vscode#43431
From @mogarick on February 11, 2018 15:46
Issue Type
Bug
Description
I have a JS project that depends on
mobxand other libs that include its own type definitions bundled and properly declared in itspackage.jsonfile under thetypingskey. I added thecheckJs: truein myjsconfig.jsonfile but vscode is having problems to recognizemobxtype defs because I'm getting the next error when importing anymobxcomponent into my project files:[js] Cannot find module 'mobx'.I'm using
mobxversion3.4.1and itspackage.jsonfile has the proper typings property with the following values:yet vscode is not recognising it.
I found a SO question that describes the same problem but for a TS project. I followed the ugly workaround by renaming
mobx.d.tstoindex.d.tsand moving the file to the root lib directory (/node_modules/mobx/index.d.ts), fixing the types paths accordingly and changing the typings property to"typings": "./index.d.ts"but the error remains.I also have
reactas dependency and I added the@types/reactas dev dependency and in this case vscode does recognises the type defs because they are in thenpm_modules/@typesdirectorySo it appears vscode is not processing the
package.jsontypings property but only the ones undernode_modules/@types.It's important to notice the the problem is not related to extensions added. It occurs with a clean vscode version. I uninstalled vscode, deleted all extensions, then re installed it and yet the problem was still there.
It's also important to notice that is not only
mobx. I have other dependencies with its type defs bundled and properly declared in itspackage.jsonfile and I get the same error message for them.VS Code Info
VS Code version: Code 1.20.0 (c63189deaa8e620f650cc28792b8f5f3363f2c5b, 2018-02-07T17:02:34.244Z)
OS version: Darwin x64 15.6.0
System Info
Extensions (9)
Copied from original issue: microsoft/vscode#43431