[英]Aurelia npm install: tons of “gyp ERR”
这些类型的问题一角钱,我经历了一个又一个资源,但似乎没有任何效果:
这是一笔交易,对于NodeJS和Aurelia来说我还很陌生,但是我的经验是,随着最近的前端革命的到来以及其所有工具的出现,人们确实使事情看起来看似简单。 我敢肯定,我们都看到过类似的命令:“只要运行do my-work-for-me
,您的项目就完成了!”
以Aurelia指南为例。 导航到工作目录后,只需执行以下操作:
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.
由getter证明,在npm中设置适用的VS版本:
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
我确实非常不喜欢回答自己的问题,但是我可以通过执行以下步骤来解决此问题:
npm
此时,我应该能够对Aurelia目录运行npm install
,但是由于问题描述中指出的错误,我仍然失败。
通过发出以下命令,明确告诉npm
使用Microsoft Studio 2013:
npm config set msvs_version 2013 --global
现在,在执行此命令之后,我能够成功执行npm install
而没有任何GYP
错误。
我不知道为什么,但是无论出于何种原因, node-gyp
似乎在2012年都无法正常运行,因此,如果您遇到此问题,我会选择2013年,此处实际上引用了该地址: https:// github.com/nodejs/node-gyp
我在Windows上,并且对节点样式的前端工具还比较陌生。 我感到你很痛苦。
节点gyp ERR!
消息是可以忽略的。 如果仔细观察,它们总是跟着npm WARN optional dep failed, continuing [some dependency]
这是许多gyp ERR!
之一的示例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
如果您已选中带有C ++的Visual Studio 2015社区部分,或Visual Studio 2015 Express for Desktop,它将放在正确的位置。
如果您需要对VM进行最少安装或仅在Windows 10 x64上不使用这些工具,则:
1-Python
安装最新的Python 2.7.x ,而不是3.x。 除非您需要其他某些工具的Python,否则不必选择要添加到PATH的选项。
2-Microsoft Visual C ++ Build Tools 2015技术预览版
不要执行默认安装,您需要同时选择Win8.1和Win 10 SDK。 这是指2015年11月20日发布的下载。
Microsoft Visual C ++ Build Tools 2015技术预览版
3-Node.js
经过稳定分支5.3.0的测试,为node-gyp添加以下全局变量。
npm --global config设置msvs_version 2015
npm-全局配置设置python c:\\ dev \\ Python27 \\ python.exe
(或安装python的任何地方,仅当您未通过安装程序添加到PATH时才需要)
而已。
git clone https://github.com/aurelia/skeleton-navigation
cd骨架导航
npm安装
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.