0

I'm trying to install graphene-pk11 node js module to interact with SoftHSM2. I'm using node v4.6.0 and npm 2.15.9

If I execute the command npm install graphene-pk11, I get the error enoent ENOENT: no such file or directory, chmod '/home/lzuniga/development/HsmTest/node_modules/graphene-pk11/build/console/console.js', which I looked up on multiple forums and tried a lot of solutions/workarounds like running npm cache clean or removing the node_modules folder.

I also downloaded the graphene source from github's repo and tried to use it as stated in neebz and theprogrammer's answers on this question (created a node_modules folder in my project folder and put graphene source folder there, then on my app.js file I added var graphene = require("graphene-pk11");), but the error was Cannot find module 'graphene-pk11'

It should be an npm issue, but I don't know if there could be a different problem in this module, since none of the solutions for the enoent error worked for me...

EDIT If I run npm install inside the graphene project directory that I downloaded and copied into the node_modules directory, I get the following output:

$ 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
Community
  • 1
  • 1
myrmix
  • 371
  • 3
  • 11
  • 25
  • Is the error message literally showing `/path-to-project/node_modules/graphene-pk11/build/console/console.js`? Because unless you have a folder called `path-to-project` in your root of course it's going to fail. Perhaps you should show the real commands you're using. – Qix - MONICA WAS MISTREATED Oct 17 '16 at 00:31
  • No, I changed it for the actual path, to avoid more confusions – myrmix Oct 17 '16 at 04:37
  • Author of this library, just saw this. Are you still having issues? If so please file a bug in the repo, happy to help out in any way. – rmhrisk Dec 09 '16 at 03:45

1 Answers1

0

There seems to be a problem with their publish to npm. The problem is that at the time of running npm install graphene-pk11, the following file that it's package.json is looking for doesn't exist.

  "bin": {
    "graphene": "./build/console/console.js"
  },

I tried installing it into a fresh directory myself and had the same problem.

You can use it if you clone the source code. After cloning, navigate to the project directory, which should be called graphene. Run npm install inside the graphene project. There's a line inside their package.json that says "postinstall": "npm run build", which automatically runs the build process after installing all necessary dependencies.

Assuming you cloned the source code into your node_modules, you can access the module as follows:

var graphene = require('graphene');

The issue you had in trying to use the source code was that you hadn't run npm install and you were trying to require graphene-pk11 rather than graphene.

We're requiring graphene here because the name of the directory inside node_modules is graphene, or at least that's the name of the directory when I cloned the source. You could always rename the project directory in node_modules to graphene-pk11, and then you would just require graphene-pk11. I tried this out on my computer and all of this worked. Let me know if you have any issues.

This would be a temporary fix though. It shouldn't be necessary to do this in order to use their code. I would open an issue on github with them if I were you. Their package.json also says "prepublish": "npm run build", which should also run the build process before publishing to npm, but for whatever reason, that didn't work out.

Hayden Braxton
  • 1,151
  • 9
  • 14
  • Yes, the project directory is called graphene, I ran `npm install` in that directory but I got the same problem, the console.js file doesn't exist. This is part of the output: `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'` – myrmix Oct 17 '16 at 04:26
  • I had already tried renaming the project directory "graphene-pk11" so that it would match the name property in package.json – myrmix Oct 17 '16 at 04:35