繁体   English   中英

Angular 导入节点包

[英]Angular import Node Package

我克隆了这个 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 的答案

你能试试这个吗:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM