0

我在 Azure 中创建了一个应用服务,并希望在其中构建和运行我的 Vue.js 应用程序。我为 VS Code 安装了 Azure 应用服务扩展,并在应用的根目录中创建了一个 .deployment 文件,其中包含以下内容:

[config]
command = bash deploy.sh

这是 deploy.sh 中的相关片段:

if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then
  cd "$DEPLOYMENT_TARGET"
  echo "Running $NPM_CMD install --production"
  eval $NPM_CMD install --production
  exitWithMessageOnError "npm install failed"
  echo "Running vue-cli-service build"
  eval "./node_modules/.bin/vue-cli-service" build
  exitWithMessageOnError "vue-cli-service build failed"
  cd - > /dev/null
fi

在本地运行npm installand命令可以正常工作,并按预期生成包含“HTML 包”的dist文件夹。但我希望在 Azure 上进行构建,以便我可以轻松地从 Git 存储库启用自动部署。build

在部署之前,我确保我的本地distnode_modules文件夹被删除。在 Azure 扩展中,我右键单击应用程序并选择“部署到 Web 应用程序...”。npm install --production成功,但vue-cli-service build命令失败,输出如下:

8:57:41 PM vue-northwind: Running vue-cli-service build
8:57:45 PM vue-northwind: internal/modules/cjs/loader.js:883
8:57:45 PM vue-northwind:   throw err;
8:57:45 PM vue-northwind:   ^
8:57:45 PM vue-northwind: An error has occurred during web site deployment.
8:57:45 PM vue-northwind: Error: Cannot find module '../package.json'
8:57:45 PM vue-northwind: vue-cli-service build failed
8:57:45 PM vue-northwind: Require stack:
8:57:45 PM vue-northwind: - D:\home\site\wwwroot
8:57:45 PM vue-northwind: ode_modules\.bin\vue-cli-service
8:57:45 PM vue-northwind:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
8:57:45 PM vue-northwind:     at Function.Module._load (internal/modules/cjs/loader.js:725:27)
8:57:45 PM vue-northwind:     at Module.require (internal/modules/cjs/loader.js:952:19)
8:57:45 PM vue-northwind:     at require (internal/modules/cjs/helpers.js:88:18)
8:57:45 PM vue-northwind:     at Object.<anonymous> (D:\home\site\wwwroot
8:57:45 PM vue-northwind: ode_modules\.bin\vue-cli-service:4:25)
8:57:45 PM vue-northwind:     at Module._compile (internal/modules/cjs/loader.js:1063:30)
8:57:45 PM vue-northwind:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
8:57:45 PM vue-northwind:     at Module.load (internal/modules/cjs/loader.js:928:32)
8:57:45 PM vue-northwind:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
8:57:45 PM vue-northwind:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
8:57:45 PM vue-northwind:   code: 'MODULE_NOT_FOUND',
8:57:45 PM vue-northwind:   requireStack: [ 'D:\\home\\site\\wwwroot\
8:57:45 PM vue-northwind: ode_modules\\.bin\\vue-cli-service' ]
8:57:45 PM vue-northwind: }
8:57:45 PM vue-northwind: internal/modules/cjs/loader.js:883\r
8:57:45 PM vue-northwind:   throw err;\r
8:57:45 PM vue-northwind:   ^\r
8:57:45 PM vue-northwind: \r
8:57:45 PM vue-northwind: Error: Cannot find module '../package.json'\r
8:57:45 PM vue-northwind: Require stack:\r
8:57:45 PM vue-northwind: - D:\home\site\wwwroot
8:57:45 PM vue-northwind: ode_modules\.bin\vue-cli-service\r
8:57:45 PM vue-northwind:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)\r
8:57:45 PM vue-northwind:     at Function.Module._load (internal/modules/cjs/loader.js:725:27)\r
8:57:45 PM vue-northwind:     at Module.require (internal/modules/cjs/loader.js:952:19)\r
8:57:45 PM vue-northwind:     at require (internal/modules/cjs/helpers.js:88:18)\r
8:57:45 PM vue-northwind:     at Object.<anonymous> (D:\home\site\wwwroot
8:57:45 PM vue-northwind: ode_modules\.bin\vue-cli-service:4:25)\r
8:57:45 PM vue-northwind:     at Module._compile (internal/modules/cjs/loader.js:1063:30)\r
8:57:45 PM vue-northwind:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\r
8:57:45 PM vue-northwind:     at Module.load (internal/modules/cjs/loader.js:928:32)\r
8:57:45 PM vue-northwind:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)\r
8:57:45 PM vue-northwind:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {\r
8:57:45 PM vue-northwind:   code: 'MODULE_NOT_FOUND',\r
8:57:45 PM vue-northwind:   requireStack: [ 'D:\\home\\site\\wwwroot\
8:57:45 PM vue-northwind: ode_modules\\.bin\\vue-cli-service' ]\r
8:57:45 PM vue-northwind: }\r
8:57:45 PM vue-northwind: D:\Program Files (x86)\SiteExtensions\Kudu\93.30421.5177\bin\Scripts\starter.cmd bash deploy.sh
8:57:49 PM vue-northwind: Deployment failed.

关于为什么构建命令失败的任何想法?

Vue.js 的引用版本是 2.6.11,Vue-CLI 是 4.5.0

4

0 回答 0