Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Npm install failed on windows 8.1. #6

Closed
crapthings opened this issue Feb 13, 2015 · 7 comments · Fixed by #9
Closed

Npm install failed on windows 8.1. #6

crapthings opened this issue Feb 13, 2015 · 7 comments · Fixed by #9

Comments

@crapthings
Copy link

  • vs2013 express
  • python 2.7.x
  • nodejs 0.12
  • node gyp upgraded with npm install -g node-gyp

Console/CLI output

@MadLittleMods
Copy link
Owner

👍

npm install usb-detection fails on Windows 8.1

  • Windows 8.1
  • Node v0.12.1

Here is my cli error output

@adrai
Copy link
Collaborator

adrai commented May 30, 2015

This module is not compatible with node 0.12 :-(

@MadLittleMods
Copy link
Owner

@adrai I am attempting to upgrade it to the new C++ APIs.

Good resources:


Currently stuck on (help appreciated 😀):

declaration.cpp, NotifyAdded

v8::Function::Cast(*addedCallback)->Call(isolate->GetCurrentContext()->Global(), 1, argv);
..\src\detection.cpp(67): error C2248: 'v8::Persistent<v8::Function,v8::NonCopyablePersistentTraits<T>>::operator *' : cannot acces
s private member declared in class 'v8::Persistent<v8::Function,v8::NonCopyablePersistentTraits<T>>' [C:\Users\madli_000\Downloads\
node-usb-detection-master\build\detection.vcxproj]
          with
          [
              T=v8::Function
          ]
          C:\Users\madli_000\.node-gyp\2.0.1\deps\v8\include\v8.h(762) : see declaration of 'v8::Persistent<v8::Function,v8::NonCop
  yablePersistentTraits<T>>::operator *'
          with
          [
              T=v8::Function
          ]

@adrai
Copy link
Collaborator

adrai commented May 30, 2015

I suggest to use: https://github.com/nodejs/nan

@MadLittleMods
Copy link
Owner

I will tackle this in the morning.

It looks like NanCallback is what I need but I still get an error when using:

NanCallback *callback = new NanCallback(addedCallback);
callback->Call(1, argv);
..\src\detection.cpp(68): error C2664: 'NanCallback::NanCallback(const NanCallback &)' : cannot convert argument 1 from 'v8::Persis
tent<v8::Function,v8::NonCopyablePersistentTraits<T>>' to 'const v8::Handle<v8::Function> &' [C:\Users\madli_000\Downloads\node-usb
-detection-master\build\detection.vcxproj]
          with
          [
              T=v8::Function
          ]
          Reason: cannot convert from 'v8::Persistent<v8::Function,v8::NonCopyablePersistentTraits<T>>' to 'const v8::Handle<v8::Fu
  nction>'
          with
          [
              T=v8::Function
          ]

I probably need to do something like this:

Handle<Value> argv[] = {
  NanNull(),
  NanNew<String>("w00t!")
};
callback->Call(2, argv);

But I am not sure what the argv types are.

Handle<Value> nan_argv[] = {
  NanNew<v8::Object>(argv[0])
};
 callback->Call(1, nan_argv);
cannot convert argument 1 from 'v8::Persistent<v8::Function,v8::NonCopyablePersistentTraits<T>>' to 'const v8::Handle<v8::Function> &'

@MadLittleMods
Copy link
Owner

I have figured out most of the transformations for the Node v0.12.x but I am stuck on this line.

I have tried the following but it results in an error and while I have done similar cast/conversion before, I can't make it work here.

v8::Local<v8::Function> callback;
callback = args[0];
// ...

// Line 169: https://github.com/KABA-CCEAC/node-usb-detection/blob/master/src/detection.cpp#L169
ListBaton* baton = new ListBaton();
strcpy(baton->errorString, "");
baton->callback = new NanCallback(callback);
..\src\detection.cpp(183): error C2248: 'v8::Persistent<v8::Value,v8::NonCopyablePersistentTraits<T>>::Persistent' : cannot acce
ss private member declared in class 'v8::Persistent<v8::Value,v8::NonCopyablePersistentTraits<T>>' [C:\Users\madli_000\Downloads
\node-usb-detection-master\build\detection.vcxproj]
          with
          [
              T=v8::Value
          ]
          C:\Users\madli_000\.node-gyp\2.0.1\deps\v8\include\v8.h(761) : see declaration of 'v8::Persistent<v8::Value,v8::NonCop
  yablePersistentTraits<T>>::Persistent'
          with
          [
              T=v8::Value
          ]

Update: I solved this by moving to NanCallback everywhere. This way I can avoid all of the casts and conversions. You can see my final code here

@MadLittleMods
Copy link
Owner

I made pull #9 that solves this issue.

You can depend on it now until the PR gets merged.

npm install git://github.com/MadLittleMods/node-usb-detection.git#add-node-v0.12.x-support --save

@adrai adrai closed this as completed in #9 May 31, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants