2013-09-26 94 views
10

我建立了一個Azure網站,並試圖使用依賴於node-gyp的示例應用程序。Node.js應用程序無法在azure網站上部署

我得到這個:

emote: > [email protected] install C:\DWASFiles\Sites\node-canvas\VirtualDirectory0\site\wwwroot\node_modules\node-salesforce\node_modules\xml2json\node_modules\node-expat 
remote: > node-gyp rebuild 
remote: 
remote: 
remote: C:\DWASFiles\Sites\node-canvas\VirtualDirectory0\site\wwwroot\node_modules\node-salesforce\node_modules\xml2json\node_modules\node-expat>node "D:\Program Files (x86)\npm\1.2.18\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
remote: Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. 
remote: MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [C:\DWASFiles\Sites\node-canvas\VirtualDirectory0\site\wwwroot\node_modules\node-salesforce\node_modules\xml2json\node_modules\node-expat\build\binding.sln] 
remote: gypnpm ERR! [email protected] install: `node-gyp rebuild` 
remote: npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1 
remote: npm ERR! 
remote: An error has occurred during web site deployment. 
remote: npm ERR! Failed at the [email protected] install script. 
remote: npm ERR! This is most likely a problem with the node-expat package, 
remote: npm ERR! not with npm itself. 
remote: npm ERR! Tell the author that this fails on your system: 
remote: npm ERR!  node-gyp rebuild 
remote: npm ERR! You can get their info via: 
remote: npm ERR!  npm owner ls node-expat 
remote: npm ERR! There is likely additional logging output above. 
remote: 
remote: npm ERR! System Windows_NT 6.2.9200 
remote: npm ERR! command "D:\\Program Files (x86)\\nodejs\\0.8.19\\node.exe" "D:\\Program Files (x86)\\npm\\1.2.18\\bin\\npm-cli.js" "install" "--production" 
remote: npm ERR! cwd C:\DWASFiles\Sites\node-canvas\VirtualDirectory0\site\wwwroot 
remote: npm ERR! node -v v0.8.19 
remote: npm ERR! npm -v 1.2.18 
remote: npm ERR! code ELIFECYCLE 
remote: npm 
remote: 
remote: Error - Changes committed to remote repository but deployment to website failed, please check log for further details. 
To https://[email protected]:443/node-canvas.git 
    ef20ef4..147856f master -> master 

人們是否有一個優雅的解決這個還是我需要旋轉一個Linux虛擬機和部署這樣的應用程序?

+0

您是否能夠將項目發佈到Azure?我使用節點畫布模塊 – psousa

回答

9

限制網站。請參閱http://azure.microsoft.com/en-us/documentation/articles/nodejs-use-node-modules-azure-apps/的本機模塊部分。

解決方法/解決方法是在Windows開發盒中安裝所有模塊,並將node_modules作爲git部署的一部分。

+2

,這不是一個很好的解決方案,自2013年10月以來的任何更新都有同樣的問題? –

+1

根據[#1076](https://github.com/projectkudu/kudu/issues/1076)它應該工作正常。您可以使用的另一種方法是[VSTS Hosted Build](https://www.visualstudio.com/en-us/docs/build/apps/node/nodejs-to-azure),它具有所有必需的依賴關係(已測試過)作品完美)。 –

+0

記住在應用程序服務/網站上啓用python,您正在安裝:) – Hulvej

4

我最近成功部署了一個Node.js應用程序/ Sails應用程序,作爲依賴於Grunt的Azure Web應用程序運行,因此也需要對node-gyp的支持。起初,我努力讓node-gyp在連續部署上運行,而不包括node_modules文件夾,但最終我成功地實現了你希望稱爲「優雅解析」的目標。 這是必要的,我的步驟如下:

  1. 確保您使用的是稍微最新版本節點和NPM(遠的如天青允許你這樣做。在我來說,我使用的節點5.4 .0和NPM 3.3.12部署到Azure上有兩種方式,我知道要做到這一點:

    • 應用程序設置:WEBSITE_NODE_DEFAULT_VERSION 5.4.0(或其他)
    • 的package.json文件:包括以下內容:在配置/ ENV/production.js文件

      "engines": {  
          "node": "5.4.0",  
          "npm": "3.3.12" 
      }, 
      
  2. 更改設置給咕嚕更多的時間來醜化或什麼的。 20多歲的默認值似乎是太低了許多應用程序在那裏,但可能有更好的方法來解決這個問題:https://github.com/balderdashy/sails/issues/2691 我把:

    hookTimeout: 60000, // 60 seconds 
    
  3. 我用.deploymentdeploy.cmd/deploy.sh(取決於您的系統)文件來自定義Azure平臺上的部署。我使用的導遊是:http://www.cptloadtest.com/2013/12/03/Git-And-Grunt-Deploy-To-Windows-Azure.aspx

    編輯:看起來像我原來的命令來運行咕嚕從deploy.cmd是不正確的,我不熟悉的bash腳本,對不起。我結束了對這個問題的腳本的一些修改:Deploying a NodeJS App to Azure Websites fails on installing NPM packages from pagages.json from deploy.cmd?
    使用這個腳本我的grunt任務運行在部署上。這裏是我的腳本的修改部分。
    部署。CMD:

    :: Setup 
    :: -----   
    
    :: ... some default parts omitted 
    
    IF NOT DEFINED GRUNT_CMD (
        :: Install grunt 
        echo Installing Grunt 
        call npm --registry "http://registry.npmjs.org/" install grunt-cli 
        IF !ERRORLEVEL! NEQ 0 goto error 
    
        :: Locally just running "grunt" would also work 
    SET GRUNT_CMD=node "%DEPLOYMENT_SOURCE%\node_modules\grunt-cli\bin\grunt" 
    ) 
    
    goto Deployment 
    
    :: Utility Functions 
    :: ----------------- 
    
    :SelectNodeVersion 
    
    :: ... some default parts omitted 
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 
    :Deployment 
    echo Handling node.js deployment. 
    echo %DEPLOYMENT_SOURCE% 
    
    echo 1. Select node version 
    call :SelectNodeVersion 
    
    echo 2. Install npm packages dev dependencies 
    IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
        pushd "%DEPLOYMENT_SOURCE%" 
        echo Cleaning NPM cache. 
        call !NPM_CMD! cache clean 
        call !NPM_CMD! install --development 
        IF !ERRORLEVEL! NEQ 0 goto error 
        popd 
    )   
    
    echo 4. Run grunt prod task 
    pushd %DEPLOYMENT_SOURCE% 
    call !GRUNT_CMD! --no-color prod 
    IF !ERRORLEVEL! NEQ 0 goto error 
    popd 
    
    echo 5. KuduSync 
    IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
        call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd" 
        IF !ERRORLEVEL! NEQ 0 goto error 
    ) 
    
    echo 6. Install npm packages production 
    IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
        pushd %DEPLOYMENT_TARGET% 
        call !NPM_CMD! install --production 
        IF !ERRORLEVEL! NEQ 0 goto error 
        popd 
    ) 
    
  4. 然後我就遇到了這個錯誤:ENOTSUP using Grunt這是值得慶幸的是最近解決:)
    所以,剩下的爲我做的是改變了deploy.sh給出語法工作我deploy.cmd。所以以前運行咕嚕deploy.cmd我包括:

    echo 3. Update erroneous glob dependency in Grunt 
    pushd "%DEPLOYMENT_SOURCE%\node_modules\grunt" 
    call :ExecuteCmd !NPM_CMD! install [email protected]^6.0.4 --save 
    IF !ERRORLEVEL! NEQ 0 goto error 
    popd 
    

我希望這有助於你們當中有些人在那裏,但我知道,那一些我所面臨的問題可能會得到解決使用最新版本的節點和npm。但是由於Azure不能提供最新版本,所以這對你們中的一些人可能仍然有幫助。

編輯:

關於:

  1. 節點的版本選擇:

    我試圖通過僅在設定的package.json它沒有更改默認設置,選擇節點版本應用程序設置(默認版本:4.2.3),我仍然得到以下錯誤:

    Node.js versions available on the platform are: 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.8.27, 0.8.28, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28, 0.10.29, 0.10.31, 0.10.32, 0.10.40, 0.12.0, 0.12.2, 0.12.3, 0.12.6, 4.0.0, 4.1.0, 4.1.2, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 5.0.0, 5.1.1, 5.3.0, 5.4.0, 5.5.0. 
    Selected node.js version 5.4.0. Use package.json file to choose a different version. 
    Selected npm version 3.3.12 
    Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml 
    3. Install npm packages 
    npm WARN deprecated [email protected]: [email protected]<2.0.0 is no longer maintained. Upgrade to [email protected]^3.0.0 
    npm WARN deprecated [email protected]: DEPRECATED. See readme: https://github.com/gruntjs/grunt-lib-contrib 
    npm WARN deprecated [email protected]: [email protected]<2.0.0 is no longer maintained. Upgrade to [email protected]^3.0.0 
    > [email protected] preinstall D:\home\site\wwwroot\node_modules\.staging\sails-bbe9b0ace9f7789c8522238af14fe27a 
    > node ./lib/preinstall_npmcheck.js 
    
    Sails.js Installation: Checking npm-version successful 
    npm WARN prefer global [email protected] should be installed with -g 
    
    > [email protected] install D:\home\site\wwwroot\node_modules\fibers 
    > node build.js || nodejs build.js 
    
    
    D:\home\site\wwwroot\node_modules\fibers>if not defined npm_config_node_gyp (node "c:\Program Files (x86)\npm\3.3.12\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release) else (node rebuild --release) 
    Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. 
        fibers.cc 
        coroutine.cc 
    ..\src\fibers.cc : fatal error C1902: Program database manager mismatch; please check your installation [D:\home\site\wwwroot\node_modules\fibers\build\fibers.vcxproj] 
    ..\src\coroutine.cc : fatal error C1902: Program database manager mismatch; please check your installation [D:\home\site\wwwroot\node_modules\fibers\build\fibers.vcxproj] 
    gyp ERR! build error 
    gyp ERR! stack Error: `msbuild` failed with exit code: 1 
    gyp ERR! stack  at ChildProcess.onExit (c:\Program Files (x86)\npm\3.3.12\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23) 
    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 6.2.9200 
    gyp ERR! command "D:\\Program Files (x86)\\nodejs\\4.2.3\\node.exe" "c:\\Program Files (x86)\\npm\\3.3.12\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release" 
    gyp ERR! cwd D:\home\site\wwwroot\node_modules\fibers 
    gyp ERR! node -v v4.2.3 
    gyp ERR! node-gyp -v v3.0.3 
    Build failed 
    

    就像你可以看到它首先指出:

    Selected node.js version 5.4.0. Use package.json file to choose a different version. 
    

    根據的package.json文件。
    然而,後來在錯誤信息,這似乎已經改變了:

    gyp ERR! node -v v4.2.3 
    

    要我,爲什麼,因爲在的package.json文件中的版本會出現此錯誤應該被覆蓋在應用程序設置的默認並不明顯。因此,要確保將兩個設置設置爲足夠高的版本(不知道節點gyp問題何時解決,但5.4.0似乎工作正常!)。