discordjs / opus

Native opus bindings for node
MIT License
192 stars 55 forks source link

Getting gyp errors when running npm install #71

Closed Cowation closed 3 years ago

Cowation commented 3 years ago

Please describe the problem you are having in as much detail as possible:

Recently I cloned the source for one of my Discord bots onto my laptop and downloaded Python along with the Visual Studio C++ build tools. After running npm install to install the needed dependencies, I was greeted with a long string of errors in my console.

Include a reproducible code sample here, if possible:

Run npm install @discordjs/opus on a Windows 10 64-bit machine with the Microsoft Store Python 3.9 package and the Visual Studio 2019 C++ Build Tools.

Further details:

Console output:

$ npm install
npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm ERR! code 1
npm ERR! path C:\Users\knoddy\Desktop\ogs-bot\node_modules\@discordjs\opus
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.15.5 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "C:\Users\knoddy\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
npm ERR! gyp info find VS using VS2019 (16.9.31025.194) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\knoddy\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\knoddy\\AppData\\Roaming\\npm\\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   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\@discordjs\\opus\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\knoddy\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\knoddy\\AppData\\Local\\node-gyp\\Cache\\14.15.5\\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=C:\\Users\\knoddy\\AppData\\Local\\node-gyp\\Cache\\14.15.5',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\knoddy\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\knoddy\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.15.5\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\@discordjs\\opus',
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   'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\@discordjs\\opus\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\knoddy\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:351:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Windows_NT 10.0.18363
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\knoddy\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\knoddy\Desktop\ogs-bot\node_modules\@discordjs\opus
npm ERR! gyp ERR! node -v v14.15.5
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
nottizii commented 3 years ago

Please try with this

Cowation commented 3 years ago

Thanks for the quick reply. However, I'm not sure how I would go about fixing the issue. Do I need to edit other files before running the installation command?

nottizii commented 3 years ago

image

Cowation commented 3 years ago

Thank you very much, this solved my problem.

nottizii commented 3 years ago

No problem!

Cowation commented 3 years ago

Yikes, when I ran node index.js to start the bot, I got yet another error. Here's the output:

$ node .
C:\Users\knoddy\Desktop\ogs-bot\node_modules\bindings\bindings.js:135
  throw err;
  ^

Error: Could not locate the bindings file. Tried:
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\build\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\build\Debug\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\build\Release\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\out\Debug\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\Debug\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\out\Release\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\Release\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\build\default\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\compiled\14.15.5\win32\x64\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\addon-build\release\install-root\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\addon-build\debug\install-root\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\addon-build\default\install-root\node_expat.node
 → C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\lib\binding\node-v83-win32-x64\node_expat.node
    at bindings (C:\Users\knoddy\Desktop\ogs-bot\node_modules\bindings\bindings.js:126:9)
    at Object.<anonymous> (C:\Users\knoddy\Desktop\ogs-bot\node_modules\node-expat\lib\node-expat.js:4:32)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Users\knoddy\Desktop\ogs-bot\node_modules\xml2json\lib\xml2json.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30) {
  tries: [
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\build\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\build\\Debug\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\build\\Release\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\out\\Debug\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\Debug\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\out\\Release\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\Release\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\build\\default\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\compiled\\14.15.5\\win32\\x64\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\addon-build\\release\\install-root\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\addon-build\\debug\\install-root\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\addon-build\\default\\install-root\\node_expat.node',
    'C:\\Users\\knoddy\\Desktop\\ogs-bot\\node_modules\\node-expat\\lib\\binding\\node-v83-win32-x64\\node_expat.node'
  ]
}
nottizii commented 3 years ago

I found this solution in StackOverflow, try it and tell me if there's any new error or something.

Cowation commented 3 years ago

Thanks for the link. Do you happen to know what parameters I should be using when running node-gyp? I think the thread is talking about some other module.

nottizii commented 3 years ago

I don't exactly know, you should go get some info about the modules that you are using, both of that responses were found by me in Bing and StackOverflow

Cowation commented 3 years ago

Oh, I just re-ran the commands that you sent before and all of a sudden it worked! I just had to delete my node_modules folder and install the dependencies again. Thanks for the help!

nottizii commented 3 years ago

Again, no problem, have a nice day!