Javascript 不导入从 git 安装的 npm 包

标签 javascript node.js npm

我的依赖项中有一个包,位于 npm 的 package.json 中。我已经通过以下方式包含了来自 github 的包-

"dependencies": {
    "@aeternity/aepp-components": "git+https://git@github.com/aeternity/aepp-components.git#feature/v3",`
}

当我运行 npm install 时,所有内容都会安装,并且我可以在 node_modules 文件夹中看到该模块。但是,当我尝试 importrun 时,npm 给出错误提示

dependancy not found
To install it, you can run: npm install --save aepp-components

我在这里做错了什么?

编辑:我用来导入的片段:

import AeButton from 'aepp-components'

最佳答案

你需要做

import { AeButton } from '@aeternity/aepp-components'

了解如何使用解构导入 AeButton@aeternity 指定文件的默认根源,并帮助您将文件导入映射到它。使用它就会起作用。您也可以在 doc 中查看这里

关于Javascript 不导入从 git 安装的 npm 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51360088/

相关文章:

javascript - 当使用来自另一个函数的参数单击按钮时,我想将用户重定向到网页?

javascript - 存储密码以登录到 3rd 方 API

javascript - Grunt 安装在 Ubuntu 上但无法正常工作

Angular CLI 生成的库 - 无法从其模块导入组件

javascript - 使用 jQuery 切换隐藏/显示 <tr>

javascript - 为什么 facebook 在 Iframe 中不起作用

node.js - 升级npm版本时出现问题

node.js - 是否有适用于 Node.js 的 Google API 库?

javascript - 如何在 jQuery/JavaScript 中扩展返回的对象

node.js - Typescript登录功能打字问题