【问题标题】:Angular import Node PackageAngular 导入节点包
【发布时间】:2019-12-26 14:17:33
【问题描述】:

我克隆了这个 Angular 项目:https://github.com/etherparty/explorer

我想在其中安装另一个模块:https://github.com/miguelmota/ethereum-input-data-decoder

我现在想在 Angular 中使用 npm 包的功能。它不起作用。

我采取的步骤:

npm install ethereum-input-data-decoder

试过了,是否有效。不!

然后我在 transactionInfosController.js 文件的第 1 行添加了导入,因为我想在那里使用新模块。

import { InputDataDecoder } from '../../ethereum-input-data-decoder';

程序部分崩溃并出现错误:

Uncaught SyntaxError: Unexpected token {

我意识到我错误地导入了节点包。

但是查看克隆的 git repo 的文件结构,我没有看到可以导入包的另一个文件。

我需要在哪里放置导入/我需要创建哪个文件?

编辑:需要 AngularJS 的答案

【问题讨论】:

  • 你在 NodeJS 中使用ethereum-input-data-decoder 包???
  • 我是通过 npm install ethereum-input-data-decoder 安装的
  • 试图让它在角度工作

标签: node.js angularjs npm module package


【解决方案1】:

你可以试试这个:

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']);

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-08-02
  • 1970-01-01
  • 2018-10-20
  • 1970-01-01
  • 2021-06-23
  • 1970-01-01
  • 1970-01-01
  • 2020-07-29
相关资源
最近更新 更多