node.js - Angular 导入节点包
问题描述
我克隆了这个有角度的项目:https ://github.com/etherparty/explorer
我想在其中安装另一个模块:https ://github.com/miguelmota/ethereum-input-data-decoder
我现在想以角度使用 npm 包的功能。它不起作用。
我采取的步骤:
npm install ethereum-input-data-decoder
试过了,是否有效。不!
然后我在 transactionInfosController.js 文件的第 1 行中添加了导入,因为我想在那里使用新模块。
import { InputDataDecoder } from '../../ethereum-input-data-decoder';
程序部分崩溃并出现错误:
Uncaught SyntaxError: Unexpected token {
我意识到我错误地导入了节点包。
但是查看克隆的 git repo 的文件结构,我没有看到可以导入包的另一个文件。
我需要在哪里放置导入/我需要创建哪个文件?
编辑:需要AngularJS的答案
解决方案
你可以试试这个:
import * as inputDataDecoder from 'ethereum-input-data-decoder'
或者正如托尼指出的那样
import InputDataDecoder as inputDataDecoder from 'ethereum-input-data-decoder'
如果您使用的是 angularjs,请尝试以下操作:
<script src='path_to_node_modules/ethereum-input-data-decoder'></script>
而不是将其导入为:
angular.module('YourApp', ['InputDataDecoder']);
推荐阅读
- django - 使用字符串字段 (CharField) 通过外键关联模型
- angular - 如何编写保护以防止用户在 Angular 6 中丢失表单数据?
- ios - 故事板转场目的地不是预期课程
- git - 如何让新的樱桃采摘分支被推上审查?
- c - 如何修复“未分配重新分配的指针”错误
- javascript - 如何使 Ember 计算属性依赖于变量的所有后代属性?
- css - 如何在响应式类中正确格式化 href?
- reactjs - 在安装了 react-redux 和 redux 模块的连接的反应路由器中无法解析模块“react-redux”
- python-sphinx - sphinx autodoc 在 readthedocs 上创建空白页面,但在本地正确包含模块文档字符串
- python - 搜索字符串中两个分隔符之间的字符