我有一个reactJS应用,它在本地运行良好。但是最近,当通过AzureDevOps上的管道构建相同的代码时,构建失败。
请让我知道为什么会这样吗?
请在构建实例的npm run运行构建任务日志下面找到
Starting: npm run build
==============================================================================
Task : npm
Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and
authenticated registries like Azure Artifacts.
Version : 1.169.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/usr/local/bin/npm --version
6.14.5
/usr/local/bin/npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.5 node/v12.18.0 linux x64"
; environment configs
userconfig = "/home/vsts/work/1/npm/20420.npmrc"
; node bin location = /usr/local/bin/node
; cwd = /home/vsts/work/1/s/client
/usr/local/bin/npm run build
error Generating JavaScript bundles failed
[BABEL] /home/vsts/work/1/s/client/.cache/production-app.js: No "exports" main resolved in
/home/vsts/work/1/s/client/node_modules/@babel/helper-compilation-targets/package.json
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! website-company@0.1.0 build: `cross-env GATSBY_THEME=brand gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the website-company@0.1.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! /home/vsts/.npm/_logs/2020-06-11T05_31_44_848Z-debug.log
> website-company@0.1.0 build /home/vsts/work/1/s/client
> cross-env GATSBY_THEME=brand gatsby build
2 info using npm@6.14.5
3 info using node@v12.18.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle website-company@0.1.0~prebuild: website-company@0.1.0
6 info lifecycle website-company@0.1.0~build: website-company@0.1.0
7 verbose lifecycle website-company@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle website-company@0.1.0~build: PATH:
/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-
bin:/home/vsts/work/1/s/client/node_modules/.bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/主页/运行程序/.dotnet/工具:/快照/ bin:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games:/ usr / local / games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin 9个详细的生命周期网站-company@0.1.0~build:CWD:/ home / vsts / work / 1 / s / client 10个愚蠢的生命周期网站-company@0.1.0~build:Args:['-c','cross-env GATSBY_THEME = brand 盖茨比大厦'] 11愚蠢的生命周期网站-company@0.1.0~build:返回:代码:1信号:空 12个信息生命周期网站-company@0.1.0~build:无法执行构建脚本
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-
lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid website-company@0.1.0
15 verbose cwd /home/vsts/work/1/s/client
16 verbose Linux 4.15.0-1083-azure
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v12.18.0
19 verbose npm v6.14.5
20 error code ELIFECYCLE
21 error errno 1
22 error website-company@0.1.0 build: `cross-env GATSBY_THEME=brand gatsby build`
22 error Exit status 1
23 error Failed at the website-company@0.1.0 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: npm run build
答案 0 :(得分:1)
production-app.js:没有解决“主要”问题 /home/vsts/work/1/s/client/node_modules/@babel/helper-compilation-targets/package.json
根据错误消息,似乎是Node.js
或babel
版本中的回归问题,请尝试遵循以下建议来解决此问题:
您可以查看this thread了解更多详细信息。
希望这会有所帮助。