Azure部署问题缺少server.js / app.js文件

时间:2017-11-02 17:20:02

标签: node.js azure gulp web-deployment kudu

我正在尝试在Azure Web应用上部署我的代码

我的package.json文件是:

{
  "name": "blur_admin",
  "version": "1.3.1",
  "devDependencies": {
    "browser-sync": "~2.18.2",
    "browser-sync-spa": "~1.0.3",
    "chalk": "~1.1.1",
    "del": "~2.2.2",
    "eslint-plugin-angular": "~0.12.0",
    "estraverse": "~4.2.0",
    "gulp": "~3.9.0",
    "gulp-angular-filesort": "~1.1.1",
    "gulp-angular-templatecache": "~2.0.0",
    "gulp-autoprefixer": "~3.1.1",
    "gulp-eslint": "~1.0.0",
    "gulp-filter": "~4.0.0",
    "gulp-flatten": "~0.3.1",
    "gulp-gh-pages": "^0.5.4",
    "gulp-inject": "~4.1.0",
    "gulp-load-plugins": "~1.4.0",
    "gulp-minify-css": "~1.2.1",
    "gulp-minify-html": "~1.0.4",
    "gulp-ng-annotate": "~2.0.0",
    "gulp-prompt": "^0.2.0",
    "gulp-protractor": "~3.0.0",
    "gulp-rename": "^1.2.2",
    "gulp-replace": "~0.5.4",
    "gulp-rev": "~7.1.2",
    "gulp-rev-replace": "~0.4.2",
    "gulp-sass": "~2.3.2",
    "gulp-shell": "^0.5.2",
    "gulp-size": "~2.1.0",
    "gulp-sourcemaps": "~1.6.0",
    "gulp-uglify": "~2.0.0",
    "gulp-useref": "~1.3.0",
    "gulp-util": "~3.0.6",
    "gulp-zip": "^3.0.2",
    "http-proxy-middleware": "~0.17.2",
    "lodash": "~4.17.2",
    "main-bower-files": "~2.13.1",
    "uglify-save-license": "~0.4.1",
    "wiredep": "~4.0.0",
    "wrench": "~1.5.8"
  },

  "engines": {
    "node": "6.11.2",
    "npm": "5.0.3"
  },
  "dependencies": {
    "lodash": "^4.17.4",
    "moment": "^2.18.1"
  }
}

我的deploy.cmd文件是

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.15
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
goto Deployment

:: Utility Functions
:: -----------------

:SelectNodeVersion

IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
  :: The following are done only on Windows Azure Websites environment
  call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%"
  IF !ERRORLEVEL! NEQ 0 goto error

  IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" (
    SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
    SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF NOT DEFINED NODE_EXE (
    SET NODE_EXE=node
  )

  SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!"
) ELSE (
  SET NPM_CMD=npm
  SET NODE_EXE=node
)

goto :EOF

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

:Deployment
echo Handling node.js deployment.

:: 1. Select node version
call :SelectNodeVersion

:: 2. Install npm packages
IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
  call :ExecuteCmd !NPM_CMD! install
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 3. Execute Gulp
IF EXIST "%DEPLOYMENT_SOURCE%\gulpfile.js" (
    call .\node_modules\.bin\gulp serve:dist
    IF !ERRORLEVEL! NEQ 0 goto error
)

:: 4. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%\dist" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.
  

网站部署期间发生错误。一个子目录或   文件D:\ home \ site \ repository \ lib已经存在。\ r \ nMissing   server.js / app.js文件,未生成web.config \ r \ nnpm WARN   生命周期用于脚本的节点二进制文件是D:\ Program Files   (x86)\ nodejs \ 6.9.1 \ node.exe但是npm正在使用D:\ Program Files   (x86)\ nodejs \ 6.11.2 \ node.exe本身。使用   --scripts-prepend-node-path选项包括节点的路径   二进制npm用。\ r \ nnpm执行WARN blur_admin@1.3.1否   存储库字段。\ r \ nnpm WARN blur_admin@1.3.1无许可证   字段。\ r \ nnpm警告包lodash包含在dev和   生产依赖。\ r \ n \ r \ nnpm WARN弃用bower@1.8.2:   ...嘘!您的项目可以随时停止工作,因为它   依赖关系可以改变。通过迁移到Yarn来防止这种情况:   https://bower.io/blog/2017/how-to-migrate-away-from-bower/ \ r \ nnpm警告   生命周期用于脚本的节点二进制文件是D:\ Program Files   (x86)\ nodejs \ 6.9.1 \ node.exe但是npm正在使用D:\ Program Files   (x86)\ nodejs \ 6.11.2 \ node.exe本身。使用   --scripts-prepend-node-path选项包括节点的路径   二进制npm是用。\ r \ n&#39; node_modules.bin \ bower&#39;执行的。不是   被认为是内部或外部命令,\ r \ noperable程序或   批处理文件。\ r \ n(节点:11612)UnhandledPromiseRejectionWarning:   未处理的promise promise(拒绝id:1):错误:错误:jquery是   未安装。尝试运行bower install或删除该组件   来自你的bower.json文件。\ r \ n \ n:\ Program Files   (86)\ SiteExtensions \捻\ 67.61027.3099 \ BIN \脚本\ starter.cmd   deploy.cmd

我正在尝试从几天但无法解决这个问题,有人可以帮忙吗? TIA

1 个答案:

答案 0 :(得分:0)

Azure App Service不支持您在6.11.2中指定的node.js版本package.json。您可以将其更改为6.9.5或任何其他可用的。

您可以在网址https://<yourappname>.scm.azurewebsites.net/api/diagnostics/runtime

中查看Azure支持的所有node.js版本