【问题标题】:dist folder on basic vue.js基本 vue.js 上的 dist 文件夹
【发布时间】:2021-03-21 07:55:00
【问题描述】:

我使用 Visual Studio 2019 创建了一个基本的 vue.js。我将它放在我的私有 Azure 服务器中的 git 上。我有一个 Windows 构建代理。

yml 用于构建,没有错误。

trigger:
- master

pool: 'Default'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

我尝试了一些“复制/归档文件”命令。 其中之一

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)/VuejsApp1'
  inputs:
    TargetFolder: '$(Build.ArtifactStagingDirectory)/VuejsApp1'

每个方法似乎都表明 dist 文件夹从未被创建。

类似问题:why is azure build pipeline not generating a dist folder for an angular build


##[section]开始:npm install and build ==================================================== ============================= 任务:命令行描述:运行命令行脚本 在 Linux 和 macOS 上使用 Bash,在 Windows 版本上使用 cmd.exe: 2.151.1 作者:微软公司帮助:https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line ==================================================== ============================= 生成脚本。 =========================== 开始命令输出===================== ====== ##[命令]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\DevOpsAgent_work_temp\2d81f910-5c00-4330-9d13-27c8c30aa7a0.cmd ""

yorkie@2.0.0 安装 C:\DevOpsAgent_work\171\s\node_modules\yorkie 节点 bin/install.js

检测到 CI,跳过 Git 挂钩安装

core-js@2.6.11 安装后 C:\DevOpsAgent_work\171\s\node_modules\core-js node -e "try{require('./postinstall')}catch(e){}"

感谢您使用 core-js (‌ https://github.com/zloirock/core-js ‌) polyfilling JavaScript 标准库!‌

该项目需要您的帮助!请考虑对 core-js 的支持 开放集体或 Patreon:‌ >‌ https://opencollective.com/core-js ‌ >‌ https://www.patreon.com/zloirock ‌

另外,core-js 的作者(‌ https://github.com/zloirock ‌) 正在寻找一个好的 工作-)‌

ejs@2.7.4 安装后 C:\DevOpsAgent_work\171\s\node_modules\ejs 节点 ./postinstall.js

感谢您安装 ‌EJS‌:使用 ‌Jake‌ JavaScript 构建构建 工具 (‌https://jakejs.com/‌)‌

npm WARN 可选跳过可选依赖:fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents): npm WARN notsup 跳过可选依赖:不支持的平台 fsevents@1.2.13: 想要 {"os":"darwin","arch":"any"}(当前: {"os":"win32","arch":"x64"}) npm WARN 可选 SKIPPING OPTIONAL 依赖:fsevents@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents): npm WARN notsup 跳过可选依赖:不支持的平台 fsevents@1.2.13: 想要 {"os":"darwin","arch":"any"}(当前: {"os":"win32","arch":"x64"}) npm WARN 可选 SKIPPING OPTIONAL 依赖:fsevents@2.1.3 (node_modules\fsevents): npm WARN notsup 跳过可选依赖:fsevents@2.1.3 不受支持的平台: 想要 {"os":"darwin","arch":"any"} (当前: {"os":"win32","arch":"x64"})

添加了来自 822 位贡献者的 1488 个包,并审核了 1492 个包 71.233s

44 个包正在寻找资金运行npm fund 了解详情

发现 6 个漏洞(1 个低、3 个中等、2 个高)运行 npm audit fix 修复它们,或运行 npm audit 了解详细信息 ##[section]整理:npm install and build

【问题讨论】:

  • 请添加步骤日志npm install and buildCopy files。还要在npm install and build' 之后添加- script: ls
  • 我为日志编辑帖子。是针对 linux 的,从来没有在 azure 上做过 dir。我从 nde 开始,也许我也需要在 yml 中安装 node,默认的 microsoft 脚本崩溃了,所以当构建没有崩溃时,我认为我不需要它。
  • dir 命令告诉我我真的没有 dist 文件夹。只是我的 git 东西和 node_modules
  • 好的。但是日志看起来像 npm install 的日志,那么 npm run build 呢?
  • 我的脚本两者兼而有之,日志适用于两者。

标签: vue.js azure-devops azure-pipelines azure-yaml-pipelines


【解决方案1】:

首先,您不需要在同一个“脚本”上进行安装和构建。

- script: 'npm install'
  displayName: 'Install dependencies'

- script: 'npm run build'
  displayName: 'Build project'

之后就可以拿到 dist 文件夹了

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)/dist'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

【讨论】:

  • 很高兴听到您解决了问题!可以accept it as an answer,让有类似问题的人受益~
  • 谢谢,这行得通,我花了几个小时试图找到与构建 React.JS 相同的问题的答案
【解决方案2】:

有两个故障排除建议:

1.尝试在本地构建,或者使用 Azure DevOps 的 PowerShell 任务运行 npm 命令,看看是否存在相同的问题。

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      npm install
      npm run build

2.检查你的json文件中的options参数是否设置为dist

  "options": {
        "outputPath": "dist",
       }

【讨论】:

  • 我没有时间测试您的 powershell 版本,如果您想为另一个添加示例,可能会有用。
  • 我需要探索json,我从不改变输出路径
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
  • 2021-01-27
  • 2018-07-13
  • 2020-08-18
  • 2018-12-10
  • 1970-01-01
相关资源
最近更新 更多