繁体   English   中英

不能在 npm 包中使用别名

[英]cannot use alias in npm package

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

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

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

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

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

import {helper} from "moduleOne"

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

试试

import { helper } from "moduleOne"

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM