簡體   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