gpt4 book ai didi

javascript - 不能在 npm 包中使用别名

转载 作者:行者123 更新时间:2023-11-30 13:58:37 25 4
gpt4 key购买 nike

我正在尝试创建一个可以在我的其他应用程序中使用的 npm 包。在我的开发中,我在 tsconfig 中定义了路径来导入不同的模块而不是相对路径。但是,当我下载我的包以测试应用程序时。它无法解析模块路径。

我想如果我改为使用相对路径那么它会起作用。

在我的 tsconfig 中,我定义了这样的路径

"moduleOne": ["./moduleOne/src/index.ts"]

在我需要导入 moduleOne 的 ts 文件中我愿意

import {helper} from "moduleOne"

当我在我的其他应用程序中下载包时,我得到模块未找到:错误:无法解析“moduleOne”

最佳答案

您在导入时缺少围绕 moduleOne 的字符串引号。

关于javascript - 不能在 npm 包中使用别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56760232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com