tsc抛出错误TS2307:找不到本地安装模块的模块

时间:2018-04-06 15:39:54

标签: typescript local yarnpkg tsc

我已经阅读了这些类似的问题:

在我的Typescript项目中,我有两个目录:

core/
  package.json
  ...
app/
  package.json
  ...

app/内我使用core/安装了yarn模块,如下所示:

yarn add file:../core

app/package.json显示为:

{
  ...
  "dependencies": {
    ...
    "my-core": "file:../core",
    ...
  }
}

在macOS和Linux上,从tsc内运行app/可以正常工作。但是当我在Windows上运行tsc时,我得到了这个:

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.

这是我的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"
  ]
}
这是一个纱虫吗?还是一个打字稿的bug?或者我做错了什么? :)

0 个答案:

没有答案