1

经过几个小时的文档和教程后,我仍然没有让我的项目运行。

如何将核心包添加到 lambda 包中?

示例存储库:https ://github.com/benkeil/yarn-berry-workspaces

yarn workspace lambda add core他向 lambda 包添加依赖项后,但 IntelliJ 说它找不到该模块。

而且我无法启动它:src/index.ts:1:21 - error TS2307: Cannot find module 'core' or its corresponding type declarations.

4

1 回答 1

0

yarn workspace lambda add core应该做的事情,但你package.json必须更正,它引用了不存在的文件。

  • 更改https://github.com/benkeil/yarn-berry-workspaces/blob/main/code/core/package.json如下:
{
  "name": "core",
  "version": "1.0.0",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "scripts": {
    "clean": "rm -rf dist",
    "prebuild": "yarn clean",
    "build": "tsc",
    "prebuild:watch": "yarn prebuild",
    "build:watch": "tsc --watch"
  },
  "devDependencies": {
    "typescript": "^4.3.4"
  }
}

(注意更改"main""types"条目)

  • yarn-berry-workspaces/blob/main/code/core/文件夹中,运行tsc

  • 重启IDE

于 2021-06-22T11:07:26.027 回答