Aurelia npm 安装:大量 "gyp ERR"
Aurelia npm install: tons of "gyp ERR"
这些类型的问题一毛钱一打,我查阅了一个又一个资源,但似乎没有任何效果:
- https://github.com/nodejs/node-gyp/issues/629
- NodeJS - Error installing with NPM
- http://blog.jimdhughes.com/2015/04/09/perils-with-node-gyp-and-windows-development/
事情是这样的,我是 NodeJS 和 Aurelia 的新手,但我的经验是,随着最近的前端革命及其所有工具的出现,人们真的让事情看起来非常简单。
我敢肯定我们都见过类似这样的命令:"just run do my-work-for-me
and your project is done!"
以Aurelia guide为例。导航到工作目录后,您需要做的就是 运行:
npm install
嗯,不。 npm install
依赖于 node-gyp
,您必须手动安装它。好吧,你不能在安装 Python 之前安装 node-gyp
。但是不要获取最新的,因为不支持 > 3.x。安装后,您会遇到 node-gyp
所需的 C++ 编译器问题。所以我们安装 Microsoft VS 2012 来获取编译器。
我做了什么:
设置PYTHON为环境变量
C:\Users\[name]>py
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
在npm中设置适用的VS版本,由getter:
证明
C:\Users\[name]>npm config get msvs_version
2012
也就是说,当我尝试从应用程序的目标目录 运行 npm install
时,我仍然遇到以下错误:
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit c
ode: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:88:13)
gyp ERR! stack at ChildProcess.emit (events.js:173:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:201:12)
gyp ERR! System Windows_NT 6.1.7601
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 C:\_workspaces\skeleton-navigation-1.0.0-beta.1.0.2\node_modules\utf-8-validate
gyp ERR! node -v v5.2.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: `node-gyp rebuild`
npm WARN install:utf-8-validate@1.2.1 Exit status 1
我在 windows 并且对节点式前端工具比较陌生。我感受到你的痛苦。
节点 gyp ERR!
消息可以安全忽略。如果你仔细观察,它们后面总是跟着 npm WARN optional dep failed, continuing [some dependency]
这里是许多 gyp ERR!
块之一的示例,您将很高兴在使用 windows 安装 npm 时看到:
C:\repos\skeleton-navigation\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node
_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp
else (node rebuild ) s\node-gyp\bin\node-gyp.js" 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:114:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:11
gyp ERR! stack at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\repos\skeleton-navigation\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.i
o-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.2.1
我真的、真的不喜欢回答我自己的问题,但我通过采取以下步骤解决了这个问题:
- 卸载Node.js
- 卸载 Microsoft Visual Studio 2012
- 卸载所有剩余的 C++ 2010 x86/x64 可再发行组件
- 重新安装Node.js
- 使用Node.js重新安装
npm
- 安装 Microsoft Studio 2013(快捷桌面)
在这一点上,我应该能够 运行 npm install
针对 Aurelia 目录,但是由于描述中指出的错误,我仍然失败了问题。
通过发出命令明确告诉 npm
使用 Microsoft Studio 2013:
npm config set msvs_version 2013 --global
现在,在这个命令之后,我能够成功执行 npm install
而没有任何 GYP
错误。
我不知道为什么,但出于某种原因 node-gyp
似乎不太适合 2012 年,所以如果您遇到这个问题,我会选择 2013 年,这实际上是此处引用:https://github.com/nodejs/node-gyp
如果您选中了 Visual Studio 2015 Community with C++ 部分,或者 Visual Studio 2015 Express for Desktop,它将放入正确的位。
如果您需要对 VM 进行最小安装或只是不在 Windows 10 x64 上使用这些工具:
1 - Python
安装最新的 Python 2.7.x,而不是 3.x。你不必 select 选项来添加到 PATH 除非你需要 Python 一些其他工具。
2 - Microsoft Visual C++ 构建工具 2015 技术预览
不要进行默认安装,您需要select Win8.1 和 Win 10 SDK。这是引用 2015 年 11 月 20 日发布的下载。
Microsoft Visual C++ Build Tools 2015 Technical Preview
3 - nodejs
使用稳定分支 5.3.0 进行测试,为 node-gyp 添加以下全局变量。
npm --global 配置集 msvs_version 2015
npm --global config set python c:\dev\Python27\python.exe
(或者你安装 python 的任何地方,只有当你没有通过安装程序添加到 PATH 时才需要)
就是这样。
git 克隆 https://github.com/aurelia/skeleton-navigation
cd 骨架导航
npm 安装
这些类型的问题一毛钱一打,我查阅了一个又一个资源,但似乎没有任何效果:
- https://github.com/nodejs/node-gyp/issues/629
- NodeJS - Error installing with NPM
- http://blog.jimdhughes.com/2015/04/09/perils-with-node-gyp-and-windows-development/
事情是这样的,我是 NodeJS 和 Aurelia 的新手,但我的经验是,随着最近的前端革命及其所有工具的出现,人们真的让事情看起来非常简单。
我敢肯定我们都见过类似这样的命令:"just run do my-work-for-me
and your project is done!"
以Aurelia guide为例。导航到工作目录后,您需要做的就是 运行:
npm install
嗯,不。 npm install
依赖于 node-gyp
,您必须手动安装它。好吧,你不能在安装 Python 之前安装 node-gyp
。但是不要获取最新的,因为不支持 > 3.x。安装后,您会遇到 node-gyp
所需的 C++ 编译器问题。所以我们安装 Microsoft VS 2012 来获取编译器。
我做了什么:
设置PYTHON为环境变量
C:\Users\[name]>py Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
在npm中设置适用的VS版本,由getter:
证明C:\Users\[name]>npm config get msvs_version 2012
也就是说,当我尝试从应用程序的目标目录 运行 npm install
时,我仍然遇到以下错误:
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit c
ode: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:88:13)
gyp ERR! stack at ChildProcess.emit (events.js:173:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:201:12)
gyp ERR! System Windows_NT 6.1.7601
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 C:\_workspaces\skeleton-navigation-1.0.0-beta.1.0.2\node_modules\utf-8-validate
gyp ERR! node -v v5.2.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: `node-gyp rebuild`
npm WARN install:utf-8-validate@1.2.1 Exit status 1
我在 windows 并且对节点式前端工具比较陌生。我感受到你的痛苦。
节点 gyp ERR!
消息可以安全忽略。如果你仔细观察,它们后面总是跟着 npm WARN optional dep failed, continuing [some dependency]
这里是许多 gyp ERR!
块之一的示例,您将很高兴在使用 windows 安装 npm 时看到:
C:\repos\skeleton-navigation\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node
_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp
else (node rebuild ) s\node-gyp\bin\node-gyp.js" 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:114:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:11
gyp ERR! stack at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\repos\skeleton-navigation\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.i
o-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.2.1
我真的、真的不喜欢回答我自己的问题,但我通过采取以下步骤解决了这个问题:
- 卸载Node.js
- 卸载 Microsoft Visual Studio 2012
- 卸载所有剩余的 C++ 2010 x86/x64 可再发行组件
- 重新安装Node.js
- 使用Node.js重新安装
npm
- 安装 Microsoft Studio 2013(快捷桌面)
在这一点上,我应该能够 运行 npm install
针对 Aurelia 目录,但是由于描述中指出的错误,我仍然失败了问题。
通过发出命令明确告诉
npm
使用 Microsoft Studio 2013:npm config set msvs_version 2013 --global
现在,在这个命令之后,我能够成功执行
npm install
而没有任何GYP
错误。
我不知道为什么,但出于某种原因 node-gyp
似乎不太适合 2012 年,所以如果您遇到这个问题,我会选择 2013 年,这实际上是此处引用:https://github.com/nodejs/node-gyp
如果您选中了 Visual Studio 2015 Community with C++ 部分,或者 Visual Studio 2015 Express for Desktop,它将放入正确的位。
如果您需要对 VM 进行最小安装或只是不在 Windows 10 x64 上使用这些工具:
1 - Python
安装最新的 Python 2.7.x,而不是 3.x。你不必 select 选项来添加到 PATH 除非你需要 Python 一些其他工具。
2 - Microsoft Visual C++ 构建工具 2015 技术预览
不要进行默认安装,您需要select Win8.1 和 Win 10 SDK。这是引用 2015 年 11 月 20 日发布的下载。
Microsoft Visual C++ Build Tools 2015 Technical Preview
3 - nodejs
使用稳定分支 5.3.0 进行测试,为 node-gyp 添加以下全局变量。
npm --global 配置集 msvs_version 2015
npm --global config set python c:\dev\Python27\python.exe
(或者你安装 python 的任何地方,只有当你没有通过安装程序添加到 PATH 时才需要)
就是这样。
git 克隆 https://github.com/aurelia/skeleton-navigation
cd 骨架导航
npm 安装