簡體   English   中英

Aurelia npm安裝:噸“ gyp ERR”

[英]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來獲取編譯器。

我所做的:

  1. 將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. 
  2. 由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

我確實非常不喜歡回答自己的問題,但是我可以通過執行以下步驟來解決此問題:

  1. 卸載Node.js
  2. 卸載Microsoft Visual Studio 2012
  3. 卸載所有剩余的C ++ 2010 x86 / x64可再發行組件
  4. 重新安裝Node.js
  5. 使用Node.js重新安裝npm
  6. 安裝Microsoft Studio 2013(Express Desktop)

此時,我應該能夠對Aurelia目錄運行npm install ,但是由於問題描述中指出的錯誤,我仍然失敗。

  1. 通過發出以下命令,明確告訴npm使用Microsoft Studio 2013:

     npm config set msvs_version 2013 --global 
  2. 現在,在執行此命令之后,我能夠成功執行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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM