我在win10下按照GitHub - nodejs/node-gyp: Node.js native addon build tool中按照Windows 10:
Install the latest version of npm (3.3.6 at the time of writing) Install Python 2.7 from Python 2.7 Release and make sure its on the System Path Install Visual Studio Community 2015 Edition. (Custom Install, Select Visual C++ during the installation) Set the environment variable GYP_MSVS_VERSION=2015 Run the command prompt as Administrator $ npm install (–msvs_version=2015) <-- Shouldn’t be needed if you have set GYP_MSVS_VERSION env If the above steps have not worked or you are unsure please visit Building using Node-GYP with Visual Studio Express 2015 on Windows 10 Pro x64 for a full walkthrough 我按照步骤来安装node-gyp,但是出现了这样的错误 npm ERR! addLocal Could not install C:\Users\Administrator\Desktop\node-gyp-master(–msvs_version=2010) npm ERR! Windows_NT 10.0.10586 npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “install” "(–msvs_version=2010)" npm ERR! node v4.3.1 npm ERR! npm v2.14.12 npm ERR! path C:\Users\Administrator\Desktop\node-gyp-master(–msvs_version=2010) npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Administrator\Desktop\node-gyp-master(–msvs_version=2010)' npm ERR! enoent This is most likely not a problem with npm itself npm ERR! enoent and is related to npm not being able to find a file. npm ERR! enoent
npm ERR! Please include the following file with any support request: npm ERR! C:\Users\Administrator\Desktop\node-gyp-master\npm-debug.log 请问怎么才是正确的安装啊?
括号不要输进去
来自酷炫的 CNodeMD
@satanmonkey 好的,谢谢,但是怎么样才是安装成功了呢?我执行了npm install –msvs_version=2015之后没有任何提示,然后执行node-gyp configure就提示node-gyp不是任何命令。
安装node-gyp命令是npm install -g node-gyp,你试一下
@dengw 是这个,非常感谢。但是请问你知道为啥执行node-gyp configure报这个错误吗?
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.0
gyp info using node@4.3.1 | win32 | x64
gyp info spawn C:\Python27\python.exe
gyp info spawn args [ ‘C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py’,
gyp info spawn args ‘binding.gyp’,
gyp info spawn args ‘-f’,
gyp info spawn args ‘msvs’,
gyp info spawn args ‘-G’,
gyp info spawn args ‘msvs_version=auto’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘C:\Users\Administrator\Desktop\node-gyp-master\build\config.gypi’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘C:\Users\Administrator\.node-gyp\4.3.1\include\node\common.gypi’,
gyp info spawn args ‘-Dlibrary=shared_library’,
gyp info spawn args ‘-Dvisibility=default’,
gyp info spawn args ‘-Dnode_root_dir=C:\Users\Administrator\.node-gyp\4.3.1’,
gyp info spawn args ‘-Dnode_gyp_dir=C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp’,
gyp info spawn args ‘-Dnode_lib_file=node.lib’,
gyp info spawn args ‘-Dmodule_root_dir=C:\Users\Administrator\Desktop\node-gyp-master’,
gyp info spawn args ‘–depth=.’,
gyp info spawn args ‘–no-parallel’,
gyp info spawn args ‘–generator-output’,
gyp info spawn args ‘C:\Users\Administrator\Desktop\node-gyp-master\build’,
gyp info spawn args ‘-Goutput_dir=.’ ]
gyp: binding.gyp not found (cwd: C:\Users\Administrator\Desktop\node-gyp-master) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp
failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js” “configure” "build"
gyp ERR! cwd C:\Users\Administrator\Desktop\node-gyp-master
gyp ERR! node -v v4.3.1
gyp ERR! node-gyp -v v3.3.0
gyp ERR! not ok
首先你得明白node-gyp是用来干啥的,然后你就知道binding.gyp not found这个错误是什么意思了。
@hanyuzhou2006 非常感谢,我忘记在那个目录下编译了