我正在尝试使用 Azure 的 Git 部署来构建和打包我的项目。
我创建了以下文件
- .部署
- 部署.cmd
- Gruntfile.js
- package.json
- bower.json
我已关注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
spa@ D:\home\site\wwwroot
+-- <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="adcfc2dac8dfed9c839a8394" rel="noreferrer noopener nofollow">[email protected]</a> extraneous
npm WARN <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="583f2a2d362c753b37362c2a313a753b373528392b2b18697668766c" rel="noreferrer noopener nofollow">[email protected]</a> requires a peer of grunt@>=0.4.0 but none was installed.
+-- UNMET PEER DEPENDENCY grunt@>=0.4.0
`-- <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e495c5b405a034d42476e1f001c001e" rel="noreferrer noopener nofollow">[email protected]</a> extraneous
spa@ D:\home\site\repository
`-- <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f7d70687a6d5f2e31283126" rel="noreferrer noopener nofollow">[email protected]</a> extraneous
spa@ D:\home\site\repository
+-- <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="52303d25372012637c657c6b" rel="noreferrer noopener nofollow">[email protected]</a> extraneous
`-- <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbbca9aeb5aff6b8b7b29beaf5e9f5eb" rel="noreferrer noopener nofollow">[email protected]</a> 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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c6a1b4b3a8b2eba5a9a8b2b4afa4eba5a9abb6a7b5b586f7e8f6e8f2" rel="noreferrer noopener nofollow">[email protected]</a> requires a peer of grunt@>=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 支持团队了解我能做什么。一旦找到任何解决方案,我就会更新问题。
最佳答案
大部分similar questions (但不适用于 azure )指向:
npm install grunt --save-dev
npm install -g grunt --save-dev
(如果您要从脚本使用 grunt
,请尝试全局 -g
安装)
This thread提到 grunt 应该安装并存在于 azure 的 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'sgrunt
itself that complains.
If I got toKudu
console and run 'grunt
' from theD:\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 thatgrunt-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 可能已安装并位于路径上,但不是 grunt-cli
期望的位置。
关于git - 通过deploy.cmd 文件部署azure Web 应用程序时,Grunt 安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37843581/