jspm install npm:fb 找不到加密

jspm install npm:fb cannot find crypto

我使用 jspm 安装 npm:fb,并在我的 js 中使用,但我得到

GET /jspm_packages/npm/crypto@0.0.3.js 404

我的步骤:

jspm init

jspm install npm:fb

我应该添加一些东西来修复它吗?

我的index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>try fb</title>
</head>
<body>
  <script src="jspm_packages/system.js"></script>
  <script src="config.js"></script>
  <script>
    System.import('lib/main.js')
  </script>
</body>
</html>

我的lib/main.js

import fb from 'fb'

export default {}

正如 jspm 在安装 fb 时所说:

warn Main entry point not found for npm:crypto@0.0.3.
     Adjust this property in the package.json or with an override, setting "main": false if this is the intention.

因此您可以将以下覆盖添加到您的 package.json:

"overrides": {
  "npm:crypto@0.0.3": {
     "main": "md5.js"
   }
}

这选择了加密模块的两个文件之一作为主要文件。这解决了原来的问题。但是你会得到另一个:

Node tls module not supported in browsers.

所以我相信你需要找到一个浏览器友好的 fb 版本。