I've read these similar questions:
tsc throws `TS2307: Cannot find module` for a local file - my problem is different because I'm installing a local package, not just referencing a local file.
error TS2307: Cannot find module (external, private module) - my problem might be similar to this one (there's not enough detail for me to tell for sure). But turning on
noResolve
causes other problems (and seems like a hack since I'm seeing a difference in behavior between macOS/Linux/Windows)
In my Typescript project, I have two directories:
core/
package.json
...
app/
package.json
...
Within app/
I have installed the core/
module using yarn
like this:
yarn add file:../core
which shows up in app/package.json
as:
{
...
"dependencies": {
...
"my-core": "file:../core",
...
}
}
On macOS and Linux, running tsc
from within app/
works fine. But when I run tsc
on Windows, I get this:
C:\proj\app>cmd /c yarn compile
yarn compile v0.27.5
$ cross-env NODE_ENV=production tsc
src/thing/appstate.ts(4,29): error TS2307: Cannot find module 'my-core'.
error Command failed with exit code 2.
Here's my app/tsconfig.json
:
{
"compilerOptions": {
"target": "es2017",
"module": "umd",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"noImplicitThis": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"sourceMap": true,
"jsx": "react",
"listEmittedFiles": false,
"lib": ["es2017", "dom"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
Is this a yarn bug? Or a Typescript bug? Or am I doing something wrong? :)