【问题标题】:Unable to import typescript module from global node_modules folder无法从全局 node_modules 文件夹导入打字稿模块
【发布时间】:2017-03-10 06:40:39
【问题描述】:

我在全局节点模块中有一个库文件夹 该库中的 library/src/index.ts 文件

//inside index.ts
export * from './components/button.component

现在我想在我的 angular-cli 应用程序中导入它 我的 angular-cli 应用有 tsconfig.ts 有 "moduleResoulution": "node"

当我收到错误“找不到模块”时如何导入它 在做

import * from 'library';

//更新

好的,所以我得到了import { ButtonComponent } from 'library/src/index 工作 但我想摆脱 src/index 部分

【问题讨论】:

    标签: typescript node-modules


    【解决方案1】:

    您需要像import * as Library from 'library' 这样声明一个命名空间。这将允许您使用 Library.ButtonComponent

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-08
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 2016-05-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多