how to install discord.js to your node.js

守給你的承諾、 提交于 2021-01-29 03:42:35

问题


i've been following a guide

https://www.youtube.com/watch?v=N5kG0bI08EQ

In that guide they use npm install discord.js in command prompt and got a success, however when i do it. i got error like this

> ref@1.3.2 install D:\Discord\node_modules\ref
> node-gyp rebuild


D:\Discord\node_modules\ref>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:401:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:356:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Discord\node_modules\ref
gyp ERR! node -v v6.6.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:ref@1.3.2 ref@1.3.2 install: `node-gyp rebuild`
npm WARN install:ref@1.3.2 Exit status 1
D:\Discord
`-- discord.js@9.3.0

npm WARN enoent ENOENT: no such file or directory, open 'D:\Discord\package.json'
npm WARN Discord No description
npm WARN Discord No repository field.
npm WARN Discord No README data
npm WARN Discord No license field.

Can anyone help me why i cant install it

Inside D:\Discord i have a folder named discord.js and the content are from https://github.com/hydrabolt/discord.js/

his result:


回答1:


In order to successfully install discord.js with voice support node-gyp is required. To install node-gyp on windows the easiest solution is to simply run npm install --global --production windows-build-tools then try the installation step again. If it fails try npm install -g npm and restart your computer.

That said from the error provided it seems you are attempting to install discord.js v6 which has not been updated in a very very long time and may no longer function at any level. The discord api is constantly changing and it may be a good idea to update to something like 8.1 which is the last release backwards compatable with code writen for 6.0



来源:https://stackoverflow.com/questions/39699596/how-to-install-discord-js-to-your-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!