我试图安装graphene-pk11 node js模块与SoftHSM2进行交互。我使用节点v4.6.0和npm 2.15.9
如果我执行命令npm install graphene-pk11
,我会收到错误enoent ENOENT: no such file or directory, chmod '/home/lzuniga/development/HsmTest/node_modules/graphene-pk11/build/console/console.js'
,我在多个论坛上查找并尝试了许多解决方案/解决方法,例如运行npm cache clean
或删除node_modules
文件夹。
我还从github's repo下载了石墨烯来源并尝试按照neebz和程序员在this question上的答案中所述使用它(在我的项目文件夹中创建了一个node_modules
文件夹并将graphene源文件夹放在那里,然后在我的app.js文件中我添加了var graphene = require("graphene-pk11");
),但错误是Cannot find module 'graphene-pk11'
这应该是一个npm问题,但我不知道这个模块中是否会出现不同的问题,因为enoent错误的解决方案都不适用于我......
修改
如果我在我下载的graphene项目目录中运行npm install
并将其复制到node_modules目录中,我会得到以下输出:
$ npm install
npm WARN package.json graphene-pk11@2.0.11 No bin file found at ./build/console/console.js
npm WARN deprecated watch@0.19.3: Install watch@1.0.0 instead
> pkcs11js@1.0.3 install /home/lzuniga/development/HsmTest/node_modules/graphene/node_modules/pkcs11js
> node-gyp rebuild
make: Entering directory `/home/lzuniga/development/HsmTest/node_modules/graphene/node_modules/pkcs11js/build'
CXX(target) Release/obj.target/pkcs11/src/main.o
CXX(target) Release/obj.target/pkcs11/src/dl.o
CXX(target) Release/obj.target/pkcs11/src/const.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/error.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/v8_convert.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/template.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/mech.o
../src/pkcs11/mech.cpp: In member function ‘void Mechanism::Free()’:
../src/pkcs11/mech.cpp:121:15: warning: deleting ‘void*’ is undefined [enabled by default]
CXX(target) Release/obj.target/pkcs11/src/pkcs11/param.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_aes.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_rsa.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_ecdh.o
CXX(target) Release/obj.target/pkcs11/src/pkcs11/pkcs11.o
CXX(target) Release/obj.target/pkcs11/src/async.o
CXX(target) Release/obj.target/pkcs11/src/node.o
SOLINK_MODULE(target) Release/obj.target/pkcs11.node
COPY Release/pkcs11.node
make: Leaving directory `/home/lzuniga/development/HsmTest/node_modules/graphene/node_modules/pkcs11js/build'
npm WARN engine http-auth@2.4.10: wanted: {"node":">=5"} (current: {"node":"4.6.0","npm":"2.15.9"})
npm WARN engine apache-crypt@1.1.2: wanted: {"node":">=5"} (current: {"node":"4.6.0","npm":"2.15.9"})
npm WARN engine apache-md5@1.0.6: wanted: {"node":">=5"} (current: {"node":"4.6.0","npm":"2.15.9"})
npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.6.0
npm ERR! npm v2.15.9
npm ERR! path /home/lzuniga/development/HsmTest/node_modules/graphene/build/console/console.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/lzuniga/development/HsmTest/node_modules/graphene/build/console/console.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/lzuniga/development/HsmTest/node_modules/graphene/npm-debug.log
答案 0 :(得分:0)
他们发布到npm似乎有问题。问题是在运行npm install graphene-pk11
时,它的package.json正在寻找的以下文件不存在。
"bin": {
"graphene": "./build/console/console.js"
},
我自己尝试将它安装到一个新目录中并遇到同样的问题。
如果克隆源代码,则可以使用它。克隆后,导航到项目目录,该目录应称为graphene
。在石墨烯项目中运行npm install。他们的package.json
中有一行代表"postinstall": "npm run build",
,它在安装所有必要的依赖项后会自动运行构建过程。
假设您将源代码克隆到node_modules中,您可以按如下方式访问该模块:
var graphene = require('graphene');
您尝试使用源代码时遇到的问题是您没有运行npm install
而您尝试使用graphene-pk11
而不是graphene
。
我们在这里要求graphene
因为node_modules中的目录名是graphene
,或者至少是我克隆源时目录的名称。您始终可以将node_modules
中的项目目录重命名为graphene-pk11
,然后您只需要graphene-pk11
。我在我的电脑上尝试了这一切,所有这一切都奏效了。如果您有任何问题,请告诉我。
这可能是一个临时修复。为了使用它们的代码,没有必要这样做。如果我是你,我会在github上打开一个问题。他们的package.json
也说"prepublish": "npm run build",
也应该在发布到npm之前运行构建过程,但无论出于什么原因,这都没有用。