azure生成失败,无法识别“ng”

mwg9r5ms  于 2021-06-24  发布在  Kudu
关注(0)|答案(0)|浏览(258)

我正在尝试用azure+“kudu”部署angular应用程序。在构建脚本中,它没有选择“ng关键字”。
我已将默认节点版本设置为更高版本
Angular 依赖也添加到依赖列表中。
我已经尝试了几乎所有的解决方案在互联网上,但不能使这个工作,有人能帮我解决这个问题吗
生成脚本结果

Command: deploy.cmd
D:\home\site\repository\
D:\home\site\repository\..\artifacts
D:\home\site\wwwroot
D:\home\site\repository
Handling node.js deployment.
before npm install
Looking for app.js/server.js under site root.
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".
The package.json file does not specify node.js engine version constraints.
Missing server.js/app.js files, web.config is not generated
The node.js application will run with the default node.js version 10.6.0.
'ng' is not recognized as an internal or external command,
Selected npm version 6.1.0
operable program or batch file.
after npm install
npm ERR! code ELIFECYCLE
package json exist
npm ERR! errno 1
if angular json exists
npm ERR! frontend-angular-app@0.0.0 build: `ng build --prod`
Building app in "D:\home\site\repository"
npm ERR! Exit status 1

我的包.json

{
  "name": "frontend-angular-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/cli": "~6.1.3",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/language-service": "^6.1.0",
    "ag-grid-angular": "^19.1.1",
    "ag-grid-community": "^19.1.1",
    "angular2-moment": "^1.9.0",
    "bootstrap": "^4.1.3",
    "chart.js": "^2.7.3",
    "core-js": "^2.5.4",
    "font-awesome": "^4.7.0",
    "moment": "^2.22.2",
    "rxjs": "^6.0.0",
    "xlsx": "^0.14.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng2-chartjs2": "^1.2.0",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

我的构建.cmd

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

echo after npm install

IF EXIST "%DEPLOYMENT_SOURCE%\angular.json" (

echo if angular json exists

  echo Building app in "%DEPLOYMENT_SOURCE%"
  call :ExecuteCmd !NPM_CMD! run build

  IF !ERRORLEVEL NEQ 0 goto error
  popd
)
echo build done
:: 1. 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.

in azure application settings 

WEBSITE_NODE_DEFAULT_VERSION:10.6.0

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题