2016-06-15 91 views
6

我正嘗試使用Azure的Git部署來構建和打包我的項目。Grunt安裝通過deploy.cmd文件在Azure Web應用程序部署上失敗

我創建下列文件

  1. .deployment
  2. deploy.cmd
  3. Gruntfile.js
  4. 的package.json
  5. bower.json

我ve遵循Jay Harris的blog post。下面給出的是deploy.cmd文件部署部分:

:: 2. Select node version 
call :SelectNodeVersion 

:: 3. Install npm packages 
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
    pushd "%DEPLOYMENT_TARGET%" 
    call :ExecuteCmd !NPM_CMD! install --production 
    IF !ERRORLEVEL! NEQ 0 goto error 
    popd 
) 

:: 4. Install bower packages 
IF EXIST "%DEPLOYMENT_TARGET%\bower.json" (
    call !NPM_CMD! install bower 
    IF !ERRORLEVEL! NEQ 0 goto error 
    call .\node_modules\.bin\bower install 
    IF !ERRORLEVEL! NEQ 0 goto error 
) 

:: 4. run grunt 
IF EXIST "%DEPLOYMENT_TARGET%\Gruntfile.js" ( 
    call !NPM_CMD! install grunt-cli 
    call .\node_modules\.bin\grunt --no-color clean common dist 
    IF !ERRORLEVEL! NEQ 0 goto error 
) 

部署失敗,以下錯誤:

Selected npm version 3.8.6 
Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml 
[email protected] D:\home\site\wwwroot 
+-- [email protected] extraneous 
npm WARN [email protected] requires a peer of [email protected]>=0.4.0 but none was installed. 
+-- UNMET PEER DEPENDENCY [email protected]>=0.4.0 
`-- [email protected] extraneous 

[email protected] D:\home\site\repository 
`-- [email protected] extraneous 

[email protected] D:\home\site\repository 
+-- [email protected] extraneous 
`-- [email protected] extraneous 

grunt-cli: The grunt command line interface (v1.2.0) 

Fatal error: Unable to find local grunt. 

If you're seeing this message, grunt hasn't been installed locally to 
your project. For more information about installing and configuring grunt, 
please see the Getting Started guide: 

http://gruntjs.com/getting-started 
An error has occurred during web site deployment. 
npm WARN [email protected] requires a peer of [email protected]>=0.4.0 but none was installed.\r\nC:\Program Files (x86)\SiteExtensions\Kudu\55.50610.2267\bin\Scripts\starter.cmd deploy.cmd 

我不知道還有什麼我需要在這裏做的就是它安裝。試圖通過網絡搜索類似的問題,但找不到任何具體的解決方案。如果有人能幫助我,這將是非常棒的。

我的package.json

{ 
    "name": "myapp", 
    "private": true, 
    "devDependencies": { 
    "autoprefixer-core": "^5.2.1", 
    "grunt": "^0.4.5", 
    "grunt-angular-templates": "^0.5.7", 
    "grunt-concurrent": "^1.0.0", 
    "grunt-contrib-clean": "^0.6.0", 
    "grunt-contrib-compass": "^1.0.0", 
    "grunt-contrib-concat": "^0.5.0", 
    "grunt-contrib-connect": "^0.9.0", 
    "grunt-contrib-copy": "^0.7.0", 
    "grunt-contrib-cssmin": "^0.12.0", 
    "grunt-contrib-htmlmin": "^0.4.0", 
    "grunt-contrib-imagemin": "^1.0.0", 
    "grunt-contrib-jshint": "^0.11.0", 
    "grunt-contrib-uglify": "^0.7.0", 
    "grunt-contrib-watch": "^0.6.1", 
    "grunt-filerev": "^2.1.2", 
    "grunt-google-cdn": "^0.4.3", 
    "grunt-jscs": "^1.8.0", 
    "grunt-newer": "^1.1.0", 
    "grunt-ng-annotate": "^0.9.2", 
    "grunt-postcss": "^0.5.5", 
    "grunt-svgmin": "^2.0.0", 
    "grunt-usemin": "^3.0.0", 
    "grunt-wiredep": "^2.0.0", 
    "imagemin": "^5.2.1", 
    "jasmine-core": "^2.4.1", 
    "jit-grunt": "^0.9.1", 
    "jshint-stylish": "^1.0.0", 
    "karma": "^0.13.22", 
    "karma-jasmine": "^1.0.2", 
    "karma-phantomjs-launcher": "^1.0.0", 
    "phantomjs-prebuilt": "^2.1.7", 
    "readable-stream": "^2.1.4", 
    "through2": "^2.0.1", 
    "time-grunt": "^1.0.0", 
    "vinyl-fs": "^2.2.1" 
    }, 
    "engines": { 
    "node": ">=0.10.0" 
    }, 
    "scripts": { 
    "test": "karma start test\\karma.conf.js" 
    } 
} 

注意:到目前爲止,還沒有找到解決辦法,我要去Azure的支持團隊要弄清楚什麼我能做的。一旦找到任何解決方案,我會更新問題。

回答

2

大部分similarquestions(不適用於蔚藍雖然)指出:

npm install grunt --save-dev 
npm install -g grunt --save-dev 

(試行全球-g安裝,如果你是使用grunt從腳本)

This thread提到咕嚕應安裝並出現在PATH中對於天藍色:

The problem is not that grunt is not found on the path (" D:\Program Files (x86)\grunt\0.1.13\grunt "). It definitely starts running, but it's grunt itself that complains.
If I got to Kudu console and run ' grunt ' from the D:\home\site\repository folder, it displays exactly the same thing.

projectkudu/kudu Issue 1150確認:

this does not happen when running Kudu locally (i.e. outside of Azure).
So maybe something funky with the runtime env on Azure Websites.

grunt issue 1459看到,檢查退出狀態的錯誤代碼:

$ echo $? 
99 

we will first rename the node_modules/grunt directory, so that grunt-cli will be unable to find local grunt. This should result in error code 99.

The expected results occur, which make me believe the misleading grunt-cli error message has confused developers into thinking that Grunt itself is returning the wrong error code.

所以在Azure中的情況下,咕嚕可以安裝和路徑上,但不在grunt-cli期望它。

+0

所以你說這沒有解決方案? – JPReddy

+0

@JPReddy我在說,如果在測試了'grunt'確實已經正確安裝(本地或全局使用'-g')並且問題依然存在,那麼您需要檢查'grunt-cli'希望在哪裏找到'grunt ',如果這證明難以捉摸,請將案例升級到Azure並查看問題是否與他們的環境相關。 – VonC

+0

你是對的,我想我已經升級到Azure支持團隊 – JPReddy

2

控制您的package.json具有以下行。

"devDependencies": { 
    "grunt": "~0.4.5", 
.. 
} 

Grunt-cli預計您的項目會出現本地咕嚕聲。這個錯誤

Fatal error: Unable to find local grunt.

是關於這個地方咕嚕聲。由於您的腳本已經執行了npm install,您只需在依賴關係中添加指向「grunt」:「〜0.4.5」行到您的package.json。

以下命令也做同樣的事情,那就是添加grunt devDependencies。

npm install grunt --save-dev 
+0

它沒有工作的隊友,我已經在package.json中有這個依賴行 – JPReddy

+0

這次是什麼錯誤? –

+0

同樣的錯誤。我的意思是,即使在這個錯誤彈出之前,依賴項輸入仍然存在 – JPReddy

相關問題