【发布时间】:2018-11-13 23:26:15
【问题描述】:
我正在尝试在 azure 门户上部署示例应用,但遇到了一些困难。
起初我只是在测试,所以我创建了一个只有 ng new poc-pwa-angular-v2 的 Angular 应用程序。之后我去了一个 Bitbucket 存储库。
在 Azure 中,我创建了一个 Web 应用程序,并在部署选项中连接了 bitbucket 并设置了我的主分支。
我尝试使用 kudu(deploy.cmd 和 .deployment)生成脚本,但在第一次部署时出现错误。
谁能给点小费?
看看我的日志。
Command: deploy.cmd
Handling node.js deployment.
Creating app_offline.htm
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'package.json'
Deleting app_offline.htm
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".
Looking for app.js/server.js under site root.
Missing server.js/app.js files, web.config is not generated
The package.json file does not specify node.js engine version constraints.
The node.js application will run with the default node.js version 10.6.0.
Selected npm version 6.1.0
> poc-pwa-angular-v2@0.0.0 postinstall D:\home\site\wwwroot
> npm run build
> poc-pwa-angular-v2@0.0.0 build D:\home\site\wwwroot
> ng build
'ng' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! poc-pwa-angular-v2@0.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the poc-pwa-angular-v2@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_35_989Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! poc-pwa-angular-v2@0.0.0 postinstall: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the poc-pwa-angular-v2@0.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
Failed exitCode=1, command="D:\Program Files (x86)\nodejs\10.6.0\node.exe" "D:\Program Files (x86)\npm\6.1.0\node_modules\npm\bin\npm-cli.js" install --production
npm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_36_053Z-debug.log
An error has occurred during web site deployment.
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".\r\nMissing server.js/app.js files, web.config is not generated\r\n'ng' is not recognized as an internal or external command,\r\noperable program or batch file.\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! poc-pwa-angular-v2@0.0.0 build: `ng build`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the poc-pwa-angular-v2@0.0.0 build script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_35_989Z-debug.log\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! poc-pwa-angular-v2@0.0.0 postinstall: `npm run build`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the poc-pwa-angular-v2@0.0.0 postinstall script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_36_053Z-debug.log\r\nD:\Program Files (x86)\SiteExtensions\Kudu\78.11022.3613\bin\Scripts\starter.cmd deploy.cmd
【问题讨论】:
-
如果你正在复制
dist目录中的构建文件(这是一件好事),你不需要src目录中的那些,也不需要调用ng serve--你只需要从dist访问index.html -
@user184994 我更新了我的徽标。我运行“ng build prod”命令在 dist 文件夹中生成文件。这是我的 package.json ` { "name": "poc-pwa-angular-v2", "version": "0.0.0", "scripts": { "ng": "ng", "start": " ng serve","build":"ng build","test":"ng test","lint":"ng lint","e2e":"ng e2e","postinstall":"npm run build" } ,`
-
是的,你还在打电话给
ng serve看那个错误信息。您无需致电ng serve-- 这仅用于本地开发。您只需提供dist目录中的文件 -
@user184994 感谢您的澄清,在这种情况下,我从 package.json 中删除了“脚本”块并再次上升,它工作了
标签: javascript angular azure azure-devops devops