【发布时间】:2022-10-25 23:45:32
【问题描述】:
我想使用module-alias 转换打字稿项目中的别名路径。首先我安装模块别名:
yarn add module-alias
在package.json 中添加配置,如下所示:
"_moduleAliases": {
"@": "."
}
但是当我使用 @ 导入模块时,显示如下错误:
Cannot find module '@/auth/extension/AuthHandler'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?ts(2792)
AuthHandler 路径是src/auth/extension/AuthHandler,为什么找不到模块?我应该怎么做才能让它工作?
【问题讨论】:
-
嗨@Dolphin,自从您发布以来,这有什么好运吗?我也在为此苦苦挣扎。 TS 路径有效,但 JS 路径无效。干杯
-
我解决了这个问题,但我不记得如何解决它,我已经尝试阅读代码但仍然没有弄清楚,它太远了。对不起。 @Stf_F
标签: typescript