2013-09-26 167 views
10

Tôi đã thiết lập một trang web Azure và tôi đang cố gắng sử dụng một ứng dụng mẫu dựa trên nút-gyp.ứng dụng node.js với nút-gyp không triển khai trên trang web azure

Tôi nhận được điều này:

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 

Do mọi người có một độ phân giải duyên dáng này hay tôi cần phải quay về một VM linux và triển khai các ứng dụng như vậy?

+0

Bạn có thể xuất bản dự án của mình lên Azure không? Tôi đang gặp vấn đề tương tự khi sử dụng mô-đun nút-vải – psousa

Trả lời

9

Giới hạn trang web. Xem phần mô-đun gốc của http://azure.microsoft.com/en-us/documentation/articles/nodejs-use-node-modules-azure-apps/.

Giải pháp/giải pháp là cài đặt tất cả các mô-đun trên hộp Windows dev và bao gồm node_modules như một phần của triển khai git.

+2

không thực sự là một giải pháp tốt, bất kỳ cập nhật nào kể từ tháng 10 năm 2013? –

+1

Theo [# 1076] (https://github.com/projectkudu/kudu/issues/1076) nó sẽ hoạt động chính xác. Một giải pháp thay thế bạn có thể sử dụng là [VSTS Hosted Build] (https://www.visualstudio.com/en-us/docs/build/apps/node/nodejs-to-azure) có tất cả các phụ thuộc cần thiết (được kiểm tra và nó hoạt động hoàn hảo). –

+0

Nhắc nhở để kích hoạt python trên dịch vụ ứng dụng/trang web mà bạn đang cài đặt trên :) – Hulvej

4

Gần đây, tôi đã triển khai thành công ứng dụng Node.js/ứng dụng Sails chạy dưới dạng ứng dụng web Azure dựa trên Grunt và do đó cũng cần hỗ trợ cho nút-gyp. Lúc đầu, tôi gặp khó khăn khi nhận được nút-gyp để chạy trên triển khai liên tục mà không bao gồm các node_modules thư mục nhưng cuối cùng tôi đã succeded với một những gì bạn hy vọng sẽ gọi là "độ phân giải duyên dáng". Các bước đó là cần thiết đối với tôi là:

  1. Hãy chắc chắn rằng bạn sử dụng một phần nào lên đến phiên bản cập nhật của Node và NPM (như xa như Azure cho phép bạn làm như vậy. Trong trường hợp của tôi, tôi sử dụng nút 5.4 . .0 và NPM 3.3.12 Triển khai trên Azure có hai cách tôi biết để làm điều này:

    • cài đặt ứng dụng: WEBSITE_NODE_DEFAULT_VERSION 5.4.0 (hoặc bất kỳ)
    • Package.json tập tin: Bao gồm:

      "engines": {  
          "node": "5.4.0",  
          "npm": "3.3.12" 
      }, 
      
  2. Thay đổi các thiết lập trong config/env/production.js tập tin để cung cấp cho grunt thêm thời gian để làm xấu đi hoặc bất cứ điều gì. Giá trị mặc định của độ tuổi 20 có vẻ là quá thấp đối với rất nhiều các ứng dụng trên mạng, tuy nhiên có thể có những cách tốt hơn để giải quyết này: https://github.com/balderdashy/sails/issues/2691 tôi đặt:

    hookTimeout: 60000, // 60 seconds 
    
  3. tôi đã sử dụng một .deployment deploy.cmd/deploy.sh (tùy thuộc vào hệ thống của bạn) tập tin để tùy chỉnh triển khai trên nền tảng Azure. Hướng dẫn tôi sử dụng là: http://www.cptloadtest.com/2013/12/03/Git-And-Grunt-Deploy-To-Windows-Azure.aspx

    EDIT: trông giống như lệnh ban đầu của tôi để chạy Grunt từ deploy.cmd là không chính xác, tôi không quen với kịch bản bash, xin lỗi. Tôi đã kết thúc bằng cách sử dụng tập lệnh từ câu hỏi này với một số sửa đổi: Deploying a NodeJS App to Azure Websites fails on installing NPM packages from pagages.json from deploy.cmd?
    Sử dụng tập lệnh này tác vụ grunt của tôi chạy khi triển khai. Dưới đây là các phần được sửa đổi của tập lệnh của tôi.
    triển khai.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. Sau đó tôi chạy vào lỗi này: ENOTSUP using Grunt được may mắn gần đây giải quyết :)
    Tất cả những gì còn lại cho tôi để làm là để thay đổi cho deploy.sh cú pháp cho những công việc trong tôi deploy.cmd. Vì vậy, trước khi chạy grunt từ deploy.cmd tôi bao gồm:

    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 
    

Tôi hy vọng điều này sẽ giúp một số bạn trên mạng, mặc dù tôi biết, rằng một số vấn đề tôi phải đối mặt có thể được giải quyết sử dụng các phiên bản cập nhật của nút và npm. Nhưng kể từ khi Azure không ra khỏi hộp cung cấp các phiên bản mới nhất này vẫn có thể hữu ích cho một số bạn.

EDIT:

Về: phiên bản

  1. Node sự lựa chọn:

    Tôi cố gắng để chọn phiên bản nút bằng cách chỉ đặt nó trong Package.json mà không thay đổi các thiết lập mặc định trong cài đặt Ứng dụng (phiên bản mặc định: 4.2.3) và tôi vẫn gặp lỗi sau:

    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 
    

    Giống như bạn có thể nhìn thấy nó tiểu bang đầu tiên:

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

    theo file Package.json.
    Tuy nhiên, sau này trong thông báo lỗi này dường như đã thay đổi:

    gyp ERR! node -v v4.2.3 
    

    Đối với tôi nó không phải là rõ ràng lý do tại sao lỗi này xảy ra kể từ khi phiên bản trong tập tin Package.json nên được ghi đè mặc định trong Cài đặt ứng dụng . Vì vậy, để chắc chắn chỉ cần thiết lập cả hai cài đặt cho một phiên bản đủ cao (không chắc chắn khi vấn đề nút-gyp đã được giải quyết, nhưng 5,4.0 dường như làm việc tốt!).