React Azure Pipeline 中的构建步骤出现 CI/CD 错误

问题描述 投票:0回答:1

当我的应用程序尝试构建反应应用程序时,我面临着管道工作。我尝试更改构建命令添加 CI= xxxxx,我还尝试更新依赖项,解决警告,并检查了服务器应用程序和客户端应用程序的路径。

这就是我的完整工作(https://i.stack.imgur.com/njxLS.png) 这是我的项目树(https://i.stack.imgur.com/4KG1l.png)

这是我的 azure-pipelines.yml

# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- task: Npm@1
  displayName: "Installing modules in /Server"
  inputs:
    command: 'install'
    workingDir: 'Server/IglesiaFiel.WebAPI'
- task: Npm@1
  displayName: "Installing modules in /Client"
  inputs:
    command: 'install'
    workingDir: 'Client/iglesiafiel.front'
- task: Npm@1
  displayName: "Building modules in /Client"
  inputs:
    command: 'custom'
    workingDir: 'Client/iglesiafiel.front'
    customCommand: 'run build'
- task: CopyFiles@2
  inputs:
    Contents: |
      Client/iglesiafiel.front/build/**
      Sertver/IglesiaFiel.WebAPI/**
    TargetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'release'
    publishLocation: 'Container'

这是整个日志:

1 verbose cli   '/opt/hostedtoolcache/node/10.24.1/x64/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: /opt/hostedtoolcache/node/10.24.1/x64/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/vsts/work/1/s/Client/iglesiafiel.front/node_modules/.bin:/opt/hostedtoolcache/node/10.24.1/x64/bin:/snap/bin:/home/vsts/.local/bin:/opt/pipx_bin:/home/vsts/.cargo/bin:/home/vsts/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/vsts/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle [email protected]~build: CWD: /home/vsts/work/1/s/Client/iglesiafiel.front
10 silly lifecycle [email protected]~build: Args: [ '-c', 'CI= react-scripts build' ]
11 silly lifecycle [email protected]~build: Returned: code: 1  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `CI= react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/opt/hostedtoolcache/node/10.24.1/x64/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/opt/hostedtoolcache/node/10.24.1/x64/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/vsts/work/1/s/Client/iglesiafiel.front
16 verbose Linux 6.5.0-1016-azure
17 verbose argv "/opt/hostedtoolcache/node/10.24.1/x64/bin/node" "/opt/hostedtoolcache/node/10.24.1/x64/bin/npm" "run" "build"
18 verbose node v10.24.1
19 verbose npm  v6.14.12
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `CI= react-scripts build`
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

##[error]Error: Npm failed with return code: 1
Finishing: Building modules in /Client

reactjs node.js azure-devops continuous-integration azure-pipelines
1个回答
0
投票

从您的屏幕截图来看,该项目包含存储库中的

node_modules
文件夹。

当前问题可能与 NPM 缓存有关。

您可以删除项目中的

node_modules
目录和
package-lock.json
文件。

然后您可以使用 Pipeline 运行

npm install
来全新安装所有软件包。

例如:

- task: Npm@1
  displayName: "Installing modules in /Client"
  inputs:
    command: 'install'
    workingDir: 'Client/iglesiafiel.front'
© www.soinside.com 2019 - 2024. All rights reserved.