为什么在Node.js上没有安装任何东西?

时间:2017-05-15 21:20:06

标签: javascript node.js

今天我决定尝试在Node.js中创建一个discord bot。当我去安装它时,我开始出错。当我发现什么都没有安装时,我开始搜索互联网以找到解决方案。例如,

C:\Users\aidan\Documents\discord bot>npm install --global --production windows-build-tools
npm WARN engine windows-build-tools@1.2.1: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine request@2.81.0: wanted: {"node":">= 4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine har-validator@4.2.1: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine har-schema@1.0.5: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
\
 windows-build-tools@1.2.1 postinstall C:\Users\aidan\AppData\Roaming\npm\node_modules\windows-build-tools
 node ./lib/index.js
Downloading BuildTools_Full.exe
[>                                            ] 0.0% (0 B/s)
Downloading python-2.7.11.msi
[>                                            ] 0.0% (0 B/s)
Downloaded python-2.7.11.msi. Saved to C:\Users\aidan\.windows-build-tools\python-2.7.11.msi.
Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!
Waiting for installers... -C:\Users\aidan\AppData\Roaming\npm\node_modules\windows-build-tools\lib\install\tailer.js:92
      if (data.includes('Variable: IsInstalled = 1') || data.includes('Variabl
               ^
TypeError: undefined is not a function
    at Tailer.handleData (C:\Users\aidan\AppData\Roaming\npm\node_modules\windows-build-tools\lib\install\tailer.js:92:16)
    at null.<anonymous> (C:\Users\aidan\AppData\Roaming\npm\node_modules\windows-build-tools\lib\install\tailer.js:72:16)
    at wrapper [as _onTimeout] (timers.js:265:14)
    at Timer.listOnTimeout (timers.js:110:15)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--global" "--production" "windows-build-tools"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code ELIFECYCL
npm ERR! windows-build-tools@1.2.1 postinstall: `node ./lib/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the windows-build-tools@1.2.1 postinstall script 'node ./lib/index.js'.
npm ERR! This is most likely a problem with the windows-build-tools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./lib/index.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls windows-build-tools
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\aidan\Documents\discord bot\npm-debug.log
C:\Users\aidan\Documents\discord bot>

是我尝试安装构建工具时得到的。我在64位计算机上使用Windows 10 Creators Update。 哦,是的,当我尝试安装discord.js时:

C:\Users\aidan\Documents\discord bot>npm install discord.js
npm WARN engine discord.js@11.1.0: wanted: {"node":">=6.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN peerDependencies The peer dependency bufferutil@^3.0.0 included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency erlpack@hammerandchisel/erlpack included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency node-opus@^0.2.5 included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency opusscript@^0.0.3 included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency sodium@^2.0.1 included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency libsodium-wrappers@^0.5.1 included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency uws@^0.14.1 included from discord.js will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN engine uws@0.14.5: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
|
> bufferutil@3.0.0 install C:\Users\aidan\Documents\discord bot\node_modules\bufferutil
> prebuild-install || node-gyp rebuild

prebuild-install info begin Prebuild-install version 2.1.2
prebuild-install info looking for local prebuild @ prebuilds\bufferutil-v3.0.0-node-v14-win32-ia32.tar.gz
prebuild-install WARN install EPERM, access 'C:\Users\aidan\AppData\Roaming\npm-cache'

C:\Users\aidan\Documents\discord bot\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
Traceback (most recent call last):
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 534, in script_main
    return main(sys.argv[1:])
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 527, in main
    return gyp_main(args)
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 503, in gyp_main
    options.circular_check)
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1867, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 402, in SelectVisualStudioVersion
    versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2015'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\aidan\Documents\discord bot\node_modules\bufferutil
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok

> uws@0.14.5 install C:\Users\aidan\Documents\discord bot\node_modules\uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0

感谢您的帮助! -Aidan

1 个答案:

答案 0 :(得分:-2)

我不使用Windows,但在Treehouse发现了这个博客。

http://blog.teamtreehouse.com/install-node-js-npm-windows

*确保安装节点1st,npm 2nd,然后安装所需的任何软件包