【问题标题】:How to properly link to nodejs curve25519 library如何正确链接到 nodejs curve25519 库
【发布时间】:2014-05-08 12:00:55
【问题描述】:

我已经克隆了 git 存储库 https://github.com/thejh/node-curve25519,然后在其中使用了 npm link。我以建议的方式使用这个库:var curve = require('curve25519');。但是我在这个片段中的curve.makeSecretKey() 行收到了这个错误:

temp.secret = crypto.randomBytes(32);
curve.makeSecretKey(temp.secret);

这是错误信息:

/Users/username/Workspaces/nodejs/myproject/server.js:59
curve.makeSecretKey(ctx.private);
      ^
TypeError: Object #<Object> has no method 'makeSecretKey'
    at handlers.(anonymous function) (/Users/username/Workspaces/nodejs/myprojet/server.js:59:8)
    at Socket.<anonymous> (/Users/username/Workspaces/nodejs/myproject/server.js:198:3)
    at Socket.EventEmitter.emit (events.js:98:17)
    at UDP.onMessage (dgram.js:440:8)

我做错了什么?这个库应该包含这样的方法。如您所见:https://github.com/thejh/node-curve25519/blob/master/index.js

【问题讨论】:

    标签: javascript node.js curve-25519


    【解决方案1】:

    您还需要从项目目录链接库。
    来自docs 的示例:

    cd ~/projects/node-redis    # go into the package directory
    npm link                    # creates global link
    cd ~/projects/node-bloggy   # go into some other package directory.
    npm link redis              # link-install the package
    

    在您的情况下,第一个包目录是 curve25519 git repo,如果我正确理解您的问题,您需要在项目目录中运行的行是 npm link curve25519

    【讨论】:

      猜你喜欢
      • 2011-05-28
      • 2021-04-03
      • 1970-01-01
      • 2012-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多