javascript - 不能在 npm 包中使用别名
问题描述
我正在尝试创建一个可以在我的其他应用程序中使用的 npm 包。在我的开发中,我在 tsconfig 中定义了用于导入不同模块而不是相对路径的路径。但是,当我下载我的包以测试应用程序时。它无法解析模块路径。
我想如果我改为使用相对路径,那么它会起作用。
在我的 tsconfig 中,我定义了这样的路径
"moduleOne": ["./moduleOne/src/index.ts"]
在我需要导入 moduleOne 的 ts 文件中
import {helper} from "moduleOne"
当我在我的其他应用程序中下载包时,我得到 Module not found: Error: Can't resolve 'moduleOne'
解决方案
尝试
import { helper } from "moduleOne"
推荐阅读
- azure-devops - NuGet 包中包含的解决方案文件与持续构建不兼容
- android - 不兼容的类型:EditText 无法转换为 String
- wso2 - 带有负载均衡器的 WSO2 EI 6.5.0 集群
- javascript - 如何将“chrome.tabs.onUpdated.addListener”作为后台.js中的回调?
- swift - 当用户向下滚动时,收缩按钮并将它们移动到导航栏
- laravel - 奇怪的问题不能添加整数值
- python-3.x - 使用变量时 imaplib 搜索返回空结果
- mysql - 将排名结果与自身进行比较,如果相等,则在其上加上“=”
- tcl - 如何将puts的输出作为输入提供给proc?
- c++ - 如何声明和定义 Poco Logger?