Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get raw socket to work with npm in Node 20. Gets compiler error about SetAccessor() #87

Open
magicmouse opened this issue Apr 8, 2024 · 7 comments

Comments

@magicmouse
Copy link

I tried downgrading the module 'nan' to 2.17 from 2.18 but that didn't help. still getting blocked
trying to get raw-socket in
i tried doing npm install nan, and installing node-gyp, but it still wants to compile the C code for the raw sockets which failes in the nan C code.

MacMini:~ edward$ sudo npm install raw-socket
npm ERR! code 1
npm ERR! path /Users/edward/node_modules/raw-socket
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! CXX(target) Release/obj.target/raw/src/raw.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.7.12 found at "/usr/local/opt/[email protected]/bin/python3.7"
npm ERR! gyp info spawn /usr/local/opt/[email protected]/bin/python3.7
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/edward/node_modules/raw-socket/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/edward/Library/Caches/node-gyp/20.12.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/edward/Library/Caches/node-gyp/20.12.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/edward/Library/Caches/node-gyp/20.12.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/edward/node_modules/raw-socket',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/raw.cc:6:
npm ERR! In file included from ../src/raw.h:23:
npm ERR! In file included from ../../nan/nan.h:176:
npm ERR! ../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
npm ERR! typedef v8::Localv8::AccessorSignature Sig;
npm ERR! ~~~~^
npm ERR! In file included from ../src/raw.cc:6:
npm ERR! In file included from ../src/raw.h:23:
npm ERR! ../../nan/nan.h:2542:8: error: no matching member function for call to 'SetAccessor'
npm ERR! tpl->SetAccessor(
npm ERR! ~~~~~^~~~~~~~~~~
npm ERR! /Users/edward/Library/Caches/node-gyp/20.12.1/include/node/v8-template.h:816:8: note: candidate function not viable: no known conversion from 'imp::Sig' (aka 'int') to 'v8::SideEffectType' for 7th argument
npm ERR! void SetAccessor(
npm ERR! ^
npm ERR! /Users/edward/Library/Caches/node-gyp/20.12.1/include/node/v8-template.h:809:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void ()(v8::Localv8::Name, const v8::PropertyCallbackInfov8::Value &)') to 'v8::AccessorGetterCallback' (aka 'void ()(Localv8::String, const PropertyCallbackInfov8::Value &)') for 2nd argument
npm ERR! void SetAccessor(
npm ERR! ^
npm ERR! 2 errors generated.
npm ERR! make: *** [Release/obj.target/raw/src/raw.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 18.7.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/edward/node_modules/raw-socket
npm ERR! gyp ERR! node -v v20.12.1
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

@TaurusSilver201
Copy link

Try using an older, compatible version of Node.js that is known to work with the raw-socket package.
If you don't need the specific functionality provided by the raw-socket package, try using a different package that provides similar functionality but is more compatible with your current Node.js version.
Rebuild the nan module:
a. Delete the node_modules folder and the package-lock.json file in your project.
b. Run npm install nan to reinstall the nan module.
c. Try installing the raw-socket package again.
Try installing a specific version of the nan module that is known to work with your Node.js version and the raw-socket package, e.g., npm install [email protected].
The raw-socket package may have specific instructions or requirements for the Node.js version and dependencies. Check the package's documentation or GitHub repository for any guidance on compatible versions or workarounds.
If the above steps don't work, try building the raw-socket package manually using the node-gyp tool by running node-gyp rebuild in the raw-socket package directory.

@magicmouse
Copy link
Author

magicmouse commented Apr 8, 2024 via email

@magicmouse
Copy link
Author

magicmouse commented Apr 8, 2024 via email

@TaurusSilver201
Copy link

Troubleshooting raw-socket installation on Node.js v20 (macOS and CentOS 6.5)

Manually rebuild the raw-socket package:
a. Clone the raw-socket package repository: git clone https://github.com/ron-ip/node-raw-socket.git
b. Navigate to the cloned repository: cd node-raw-socket
c. Install the dependencies: npm install
d. Rebuild the package using node-gyp: node-gyp rebuild
e. If the rebuild is successful, you can try installing the package globally: npm install -g .

Please note that the manual rebuild process may require some additional troubleshooting and expertise with C++ and Node.js addon development. If you're not comfortable with this, the other options (using a different package or downgrading Node.js) may be more suitable for your use case.

@stephenwvickers
Copy link
Collaborator

Sorry for the lack of attention, I have struggled over the years to commit anytime to this project.

I've just published raw-socket 1.8.1 and net-ping 1.2.4, these seem to work with node 20 on my test system (net-ping uses raw-socket):

[stephen@dev-centos8 node-raw-socket]$ node -v
v20.12.1
[stephen@dev-centos8 node-net-ping]$ sudo ~/.nvm/versions/node/v20.12.1/bin/node ./example/ping.js 192.168.68.1 192.168.68.12 192.168.68.13
[sudo] password for stephen:
192.168.68.1: Alive
192.168.68.12: Alive
192.168.68.13: Not alive

For existing installations you may need to rebuild certain deps, the key one is raw-socket being 1.8.1.

@silverbullettruck2001
Copy link

silverbullettruck2001 commented Aug 19, 2024

@stephenwvickers there still seems to be issues with this on Windows. Is there a way to get this updated to work with Windows as well?

When I try to npm i to add this dependency it fails. If I take out pingus it builds successfully. It appears to be something wrong with raw-socket. All the other dependencies do not have issues installing, just pingus.

$ npm i
npm error code 1
npm error path C:\Users\user\Repos\vendor-data-sync\node_modules\raw-socket
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm error gyp info it worked if it ends with ok
npm error gyp info using [email protected]
npm error gyp info using [email protected] | win32 | x64
npm error gyp info find Python using Python version 3.12.5 found at "C:\Users\user\AppData\Local\Programs\Python\Python312\python.exe"
npm error gyp ERR! find VS
npm error gyp ERR! find VS msvs_version not set from command line or npm config
npm error gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm error gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details.
npm error gyp ERR! find VS
npm error gyp ERR! find VS Failure details: undefined
npm error gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details.
npm error gyp ERR! find VS
npm error gyp ERR! find VS Failure details: undefined
npm error gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details.
npm error gyp ERR! find VS
npm error gyp ERR! find VS Failure details: undefined
npm error gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details.
npm error gyp ERR! find VS
npm error gyp ERR! find VS Failure details: undefined
npm error gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
npm error gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm error gyp ERR! find VS
npm error gyp ERR! find VS **************************************************************
npm error gyp ERR! find VS You need to install the latest version of Visual Studio
npm error gyp ERR! find VS including the "Desktop development with C++" workload.
npm error gyp ERR! find VS For more information consult the documentation at:
npm error gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm error gyp ERR! find VS **************************************************************
npm error gyp ERR! find VS
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm error gyp ERR! stack at VisualStudioFinder.fail (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:116:11)
npm error gyp ERR! stack at VisualStudioFinder.findVisualStudio (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:72:17)
npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm error gyp ERR! stack at async createBuildDir (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:95:26)
npm error gyp ERR! stack at async run (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18)
npm error gyp ERR! System Windows_NT 10.0.22631
npm error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm error gyp ERR! cwd C:\Users\user\Repos\vendor-data-sync\node_modules\raw-socket
npm error gyp ERR! node -v v20.15.1
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: C:\Users\user\AppData\Local\npm-cache\_logs\2024-08-19T17_47_01_927Z-debug-0.log

@stephenwvickers
Copy link
Collaborator

@silverbullettruck2001 it looks like it can’t find your VC installation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants