简体   繁体   中英

jspm install npm:fb cannot find crypto

I use jspm to intall npm:fb , and use in my js, but I get

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

my step:

jspm init

jspm install npm:fb

Should I add something to fix it?

My 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>

My lib/main.js

import fb from 'fb'

export default {}

As jspm says during the installation of 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.

So you can add the following override to your package.json:

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

This chooses one of two files of the crypto module as main. This fixes the original problem. But you will get another one:

Node tls module not supported in browsers.

So I believe you need to find a browser-friendly version of fb.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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