NativeScriptException:无法找到模块:"crypto" [英] NativeScriptException: Failed to find module: "crypto"

查看:155
本文介绍了NativeScriptException:无法找到模块:"crypto"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在nativescript中运行openpgp库以使用其加密,在尝试使用它安装并运行它之后,出现此错误

JS: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ERROR Error: Uncaught (in promise): Error: com.tns.NativeScriptException: Failed to find module: "crypto", relative to: app/tns_modules/

我的package.json就是这样

  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@mattiasbuelens/web-streams-polyfill": "^0.3.2",
    "address-rfc2822": "^2.0.4",
    "asmcrypto.js": "^2.3.2",
    "asn1.js": "^5.0.1",
    "bn.js": "^4.11.8",
    "browserify-derequire": "^1.0.0",
    "buffer": "^5.2.1",
    "compressjs": "^1.0.3",
    "crypto-js": "^3.1.9-1",
    "elliptic": "^6.4.1",
    "hash.js": "^1.1.7",
    "nativescript-angular": "^7.2.3",
    "nativescript-localstorage": "^2.0.0",
    "nativescript-nodeify": "^0.8.0",
    "nativescript-theme-core": "~1.0.4",
    "node-fetch": "^2.3.0",
    "node-localstorage": "^1.3.1",
    "openpgp": "^4.4.10",
    "reflect-metadata": "~0.1.12",
    "rusha": "^0.8.13",
    "rxjs": "~6.3.0",
    "rxjs-compat": "^6.4.0",
    "tns-core-modules": "^5.4.0-next-2019-03-29-153458-02",
    "web-stream-tools": "0.0.1",
    "zone.js": "~0.8.26"
   }

如果有人知道某事,请您告诉我, 如果您知道如何在本机脚本中使用开放式pgp库,那将非常有帮助

if anyone knows of something please could you tell me, and if you know how to use the open pgp library in native script it would be very helpful

推荐答案

您可以使用我的openpgp.js v2.5.9的分支,其中包括一些polyfill,可让openpgp.js在Nativescript上工作​​.您只需要执行npm install github:mohammadrafigh/nativescript-openpgpjs#openpgp2并像这样导入openpgp:

You can use my fork of openpgp.js v2.5.9 which includes some polyfills to let openpgp.js work on Nativescript. you just need to do npm install github:mohammadrafigh/nativescript-openpgpjs#openpgp2 and import openpgp like this:

import * as openpgp from "openpgp/dist/openpgp";

我将使用来自openpgp 4的最新更改来更新此存储库,并尽快将其作为单独的软件包发布在npm上,但现在请确保您使用的是openpgp2分支而不是master.

I will update this repo with latest changes from openpgp 4 and publish it on npm as a separate package soon, but for now make sure you are using openpgp2 branch and not master.

这篇关于NativeScriptException:无法找到模块:"crypto"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆