我有一个Vue项目,它在我的机器上编译得很好。今天,我开始在Azure DevOps平台上开始部署设置,这似乎运行正常,直到调用“npm run build”。从那里,我收到多个“ELIFECYCLE”错误,这对我没什么帮助。到目前为止我尝试过的:
npm clean cache
删除node_modules和package-lock.json并使用cmd delete remove命令我在这里错过了什么?
[command]C:\windows\system32\cmd.exe /D /S /C "C:\npm\prefix\npm.cmd run build"
- Building for production...
ERROR Build failed with errors.
> [email protected] build D:\_work\1\s
npm ERR! code ELIFECYCLE
> vue-cli-service build
npm ERR! errno 1
npm ERR! [email protected] build: `vue-cli-service build`
npm ERR! Exit status 1
ERROR Failed to compile with 1 errors9:12:59 PM
npm ERR!
npm ERR! Failed at the [email protected] build script.
This relative module was not found:
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
* ./Router in ./src/main.js
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache\_logs\2019-02-26T21_13_00_370Z-debug.log
Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache\_logs\2019-02-26T21_13_00_370Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\npm\\prefix\\node_modules\\npm\\bin\\npm-cli.js',
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: C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\_work\1\s\node_modules\.bin;C:\agents\2.147.1\externals\git\cmd;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\dotnet;C:\npm\prefix;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\ProgramData\Chocolatey\bin;C:\Users\packer\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Docker;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Subversion\bin;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps
9 verbose lifecycle [email protected]~build: CWD: D:\_work\1\s
10 silly lifecycle [email protected]~build: Args: [ '/d /s /c', 'vue-cli-service 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: `vue-cli-service build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess.<anonymous> (C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd D:\_work\1\s
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\npm\\prefix\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v10.15.1
19 verbose npm v6.7.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `vue-cli-service 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
##[section]Finishing: npm run build
虽然不能直接回答你的问题,但在处理Azure DevOps托管代理上的节点时,我发现我确实遇到了一些随机错误,所以我转而使用容器来构建这些(在托管代理内部)并且我的所有错误都消失了:
jobs:
- job: build_server
pool:
vmImage: 'Ubuntu-16.04'
steps:
# build
- script: |
docker run -v $(Build.SourcesDirectory):/npm node:10.15 bash \
-c "cd /npm && npm install && npm run web-build"
# package
- task: Docker@1
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: ${{ parameters.registryName }}
imageName: ${{ format('clarity2/{0}/$(Build.SourceBranchName):$(Build.BuildNumber)', parameters.solutionName) }}
includeLatestTag: true
dockerFile: dockerfile
- task: Docker@1
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: ${{ parameters.registryName }}
imageName: ${{ format('clarity2/{0}/$(Build.SourceBranchName)', parameters.solutionName) }}
command: push
最后,这是“./Router”下的案例。仔细看,日志表明:
This relative module was not found:
* ./Router in ./src/main.js
这里的第一个问题是这些行在日志文件中没有相互跟随,所以很难解释。
在我的机器上,“。/ Ruby”被正确命名,但在repo上它有一个小写,这混淆了构建过程。但是很难追踪。