"npm run build" error when building on VSTS/Azure DevOps - azure

I have a Vue project which compiles just fine on my machine. Today, I went and started its deploy setup on the Azure DevOps platform, which seems to run ok until "npm run build" is called. From there, I receive multiple "ELIFECYCLE" errors, what doesn't help me much.
What I've tried so far:
Tried deleting both node_modules and package-lock.json with npm clean cache and using cmd delete remove command
Tried on a Linux and Windows production machines
What am I missing here?
[command]C:\windows\system32\cmd.exe /D /S /C "C:\npm\prefix\npm.cmd run build"
- Building for production...
ERROR Build failed with errors.
> appwork-vue-starter#1.2.1 build D:\_work\1\s
npm ERR! code ELIFECYCLE
> vue-cli-service build
npm ERR! errno 1
npm ERR! appwork-vue-starter#1.2.1 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 appwork-vue-starter#1.2.1 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 npm#6.7.0
3 info using node#v10.15.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle appwork-vue-starter#1.2.1~prebuild: appwork-vue-starter#1.2.1
6 info lifecycle appwork-vue-starter#1.2.1~build: appwork-vue-starter#1.2.1
7 verbose lifecycle appwork-vue-starter#1.2.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle appwork-vue-starter#1.2.1~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 appwork-vue-starter#1.2.1~build: CWD: D:\_work\1\s
10 silly lifecycle appwork-vue-starter#1.2.1~build: Args: [ '/d /s /c', 'vue-cli-service build' ]
11 silly lifecycle appwork-vue-starter#1.2.1~build: Returned: code: 1 signal: null
12 info lifecycle appwork-vue-starter#1.2.1~build: Failed to exec build script
13 verbose stack Error: appwork-vue-starter#1.2.1 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 appwork-vue-starter#1.2.1
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 appwork-vue-starter#1.2.1 build: `vue-cli-service build`
22 error Exit status 1
23 error Failed at the appwork-vue-starter#1.2.1 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

while not a direct answer to your question, when dealing with node on Azure DevOps hosted agents I found that I do get some random errors, so I switched to using a container to build those (inside hosted agents) and all my errors went away:
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

In the end, it was a case matter under "./Router". On a closer look, the log stated that:
This relative module was not found:
* ./Router in ./src/main.js
The first problem here is that these lines were NOT following each other on the log file, so hard to interpret.
On my machine, "./Router" was correctly named, but on the repo it had a lower case, which confused the build process. Hard to track, though.

Related

Looking for possible reasons why Next.js Node Server crashes: "npm ERR! code ELIFECYCLE errno 3221225477"

This happened on node version 14.16.0. I encountered the error twice now.
The first time i created a react component with the #mui/lab/DateTimePicker.
I didn't have to install it since #mui/lab was already existing in the project. (tried to reproduce this on another branch(very few changes apart). Didn't work so probably has nothing to do with mui itself)
The second time was also the second approach to the time input component. Using another simpler node module which i had to install this time. (also couldn't reproduce this case) (worked like a charm the second time)
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from C:\develop\strapi-nextjs-poc\nextjs\.env
info - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
event - compiled successfully in 5.7s (2008 modules)
wait - compiling /...
info - Using external babel configuration from C:\develop\strapi-nextjs-poc\nextjs\.babelrc
[styled-jsx] Loading plugin from path: C:\develop\strapi-nextjs-poc\nextjs\node_modules\#styled-jsx\plugin-sass\index.js
event - compiled successfully in 6.9s (2236 modules)
npm ERR! code ELIFECYCLE
npm ERR! errno 3221225477
npm ERR! nextjs#0.1.0 dev: `next dev`
npm ERR! Exit status 3221225477
npm ERR!
npm ERR! Failed at the nextjs#0.1.0 dev 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! C:\Users\sk\AppData\Roaming\npm-cache\_logs\2022-02-17T12_52_28_233Z-debug.log
/c/Program Files/nodejs/npm: line 37: 3732 Segmentation fault "$NODE_EXE" "$NPM_CLI_JS" "$#"
Reverting the current changes sadly doesn't do anything. Even after removing all changes since the last working commit, the branch is still broken.
What i tried so far (in this order):
remove dependencies from sourcecode und package json (just removed everything since last working commit)
deleted .nextjs folder (for caching)
deleted node_modules folder
using nvm to remove the current node version and re-installing it
npm cache clean --force
npm install
After encoutering the error once, it seems to be a permanent issue on the branch (even for other people pulling). So the branch is basicly not useable anymore.
The only way i found to fix the recurrence of the error was upgrading node. Tried with v14.19.0
This just brings the problem of other possible problems with the node version in the project.
Any ideas why this is happening, what causes it or what might fix it?
full log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev'
1 verbose cli ]
2 info using npm#6.14.11
3 info using node#v14.16.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle nextjs#0.1.0~predev: nextjs#0.1.0
6 info lifecycle nextjs#0.1.0~dev: nextjs#0.1.0
7 verbose lifecycle nextjs#0.1.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle nextjs#0.1.0~dev: PATH: C:\Users\sk\AppData\Roaming\nvm\v14.16.0\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\develop\strapi-nextjs-poc\nextjs\node_modules\.bin;C:\Users\sk\bin;C:\Users\sk\AppData\Local\Programs\Git\mingw64\bin;C:\Users\sk\AppData\Local\Programs\Git\usr\local\bin;C:\Users\sk\AppData\Local\Programs\Git\usr\bin;C:\Users\sk\AppData\Local\Programs\Git\usr\bin;C:\Users\sk\AppData\Local\Programs\Git\mingw64\bin;C:\Users\sk\AppData\Local\Programs\Git\usr\bin;C:\Users\sk\bin;C:\Python39\Scripts;C:\Python39;C:\Program Files\Zulu\zulu11.35.13-ca-jdk11.0.5-win_x64\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python38\Scripts;C:\Python38;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Users\adminal\.jpm\windows\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Users\sk\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\sk\AppData\Local\Microsoft\WindowsApps;C:\Users\sk\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\sk\AppData\Local\Programs\Git\usr\bin\vendor_perl;C:\Users\sk\AppData\Local\Programs\Git\usr\bin\core_perl
9 verbose lifecycle nextjs#0.1.0~dev: CWD: C:\develop\strapi-nextjs-poc\nextjs
10 silly lifecycle nextjs#0.1.0~dev: Args: [ '/d /s /c', 'next dev' ]
11 silly lifecycle nextjs#0.1.0~dev: Returned: code: 3221225477 signal: null
12 info lifecycle nextjs#0.1.0~dev: Failed to exec dev script
13 verbose stack Error: nextjs#0.1.0 dev: `next dev`
13 verbose stack Exit status 3221225477
13 verbose stack at EventEmitter.<anonymous> (C:\Users\sk\AppData\Roaming\nvm\v14.16.0\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\sk\AppData\Roaming\nvm\v14.16.0\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:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid nextjs#0.1.0
15 verbose cwd C:\develop\strapi-nextjs-poc\nextjs
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v14.16.0
19 verbose npm v6.14.11
20 error code ELIFECYCLE
21 error errno 3221225477
22 error nextjs#0.1.0 dev: `next dev`
22 error Exit status 3221225477
23 error Failed at the nextjs#0.1.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3221225477, true ]
Based on error code - it looks like a win32 access violation error as detailed here
NodejS 14.6 is on maintenance mode - consider upgrading to 16 or 17
https://nodejs.org/en/about/releases/

package.json bug with npm init -y install

I installed node.js for the sake of sass compiling, i havent touched any of javascript for now so all the documentation I went through to solve this problem is really complicated for me. So when i put npm init -y command in VScode terminal it installs package.json file that has a debug property between line 5 and 6.
when i click on "debug" errors that show into my terminal are these...
"Error: no test specified"
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! c#1.0.0 test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the c#1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AppData\Roaming\npm-cache\_logs\2020-09-27T00_42_32_091Z-debug.log
Waiting for the debugger to disconnect...
PS C:\Users\Desktop\c>
And here is log file
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'test'
1 verbose cli ]
2 info using npm#6.14.8
3 info using node#v14.11.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle c#1.0.0~pretest: c#1.0.0
6 info lifecycle c#1.0.0~test: c#1.0.0
7 verbose lifecycle c#1.0.0~test: unsafe-perm in lifecycle true
8 verbose lifecycle c#1.0.0~test: PATH: C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\\Desktop\c\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Users\\AppData\Local\Microsoft\WindowsApps;C:\Users\\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\\AppData\Roaming\npm
9 verbose lifecycle c#1.0.0~test: CWD: C:\Users\\Desktop\c
10 silly lifecycle c#1.0.0~test: Args: [ '/d /s /c', 'echo "Error: no test specified" && exit 1' ]
11 silly lifecycle c#1.0.0~test: Returned: code: 1 signal: null
12 info lifecycle c#1.0.0~test: Failed to exec test script
13 verbose stack Error: c#1.0.0 test: `echo "Error: no test specified" && exit 1`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1047:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid c#1.0.0
15 verbose cwd C:\Users\\Desktop\c
16 verbose Windows_NT 10.0.19041
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
18 verbose node v14.11.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error c#1.0.0 test: `echo "Error: no test specified" && exit 1`
22 error Exit status 1
23 error Failed at the c#1.0.0 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
VScode is giving you a quick way of running 'npm test', which is running exactly as expected. You can specify commands to run in the "scripts" property. As you can see, there is one for "test", which is outputting exactly what is written there. That is what 'debug' does. You need to hook a real test command there for debug to do anything useful.
That debug stuff is the output for a npm run test which you don't care about if you're only installing a package.json so you can install sass for development. If you want to be able to run tests via npm run test, change the value of the key/value pair on line 7 to run your tests.
"test": "someTestCommand.exe"
But again, if you're only doing this to get sass compiling, you can safely ignore it.

NG Build fails in Azure Pipelines with NPM error 134

Approx 50% of my hosted builds are failing with npm error 134. I am building the same commit with the same build definition using hosted vs2017. I am building an Angular Application using the Angular CLI. The npm task calls 'run build' which is defined as "ng build --prod" in my package.json. Both a successful build and failed build are using npm task version 1.1.49 and npm verion 6.8. This leads me to believe it is something related to the hosted environment. The hosted vs2017 and vs2019 agents fail almost all of the time. While the windows container agent fails about 50% of the time.
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! my-app#1.0.0 build: `ng build --prod`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the my-app#1.0.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! C:\npm\cache\_logs\TimeStampHere-debug.log
Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache\_logs\TimeStampHere-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 npm#6.8.0
3 info using node#v10.15.2
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle my-app#1.0.0~prebuild: my-app#1.0.0
6 info lifecycle my-app#1.0.0~build: my-app#1.0.0
7 verbose lifecycle my-app#1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle my-app#1.0.0~build: PATH: C:\npm\prefix\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;d:\a\1\s\ngmyapp\node_modules\.bin;C:\agents\2.149.2\externals\git\cmd;C:/hostedtoolcache/windows/Python/3.6.8/x64;C:/hostedtoolcache/windows/Python/3.6.8/x64/Scripts;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS\;C:\Program Files\Boost\1.69.0;C:\Users\VssAdministrator\.dotnet\tools;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\Java\zulu-8-azure-jdk_8.36.0.1-8.0.202-win_x64\bin;C:\npm\prefix;C:\hostedtoolcache\windows\Ruby\2.5.0\x64\bin;C:\Go1.11.5\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;C:\Program Files\Microsoft MPI\Bin\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Docker;C:\Program Files\PowerShell\6\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\Subversion\bin;C:\Program Files\nodejs\;C:\Program Files\CMake\bin;C:\Program Files\Mercurial;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\OpenSSL\bin;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps;
9 verbose lifecycle my-app#1.0.0~build: CWD: d:\a\1\s\ngmyapp
10 silly lifecycle my-app#1.0.0~build: Args: [ '/d /s /c', 'ng build --prod' ]
11 silly lifecycle my-app#1.0.0~build: Returned: code: 134 signal: null
12 info lifecycle my-app#1.0.0~build: Failed to exec build script
13 verbose stack Error: my-app#1.0.0 build: `ng build --prod`
13 verbose stack Exit status 134
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 my-app#1.0.0
15 verbose cwd d:\a\1\s\myapp
16 verbose Windows_NT 10.0.14393
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.2
19 verbose npm v6.8.0
20 error code ELIFECYCLE
21 error errno 134
22 error my-app#1.0.0 build: `ng build --prod`
22 error Exit status 134
23 error Failed at the my-app#1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 134, true ]
##[error]Error: Npm failed with return code: 134
##[section]Finishing: npm build
EDIT: I have configured a build agent on premise and I am not running into the issue.
It seems the root of issue is with node.js running out of memory.
https://github.com/angular/angular-cli/issues/13734
The suggested work around is to change a environment variable:
node --max_old_space_size=8192 node_modules/#angular/cli/bin/ng build --prod
In our case we use Jenkins build server but get the same error. I solved it by swithing the logging of the build progress off with the progress=false option.
Our SPA is hosted in a Visual Studio project so the option is added to the build command in the *.csproj file
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod --progress=false" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod --progress=false" Condition=" '$(BuildServerSideRenderer)' == 'true' " />

Docker build for React App failing in Gitlab CI runner

I have been trying to create a react app Gitlab CI but it keeps failing on the RUN npm run build (tried RUN CI=true npm run build too) when trying to create a docker file.
Here's my Dockerfile
FROM node:8.11.1
# Create app directory
WORKDIR /app/
# Install app dependencies
RUN npm -g install serve
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json /app/
RUN npm install
# Bundle app source
COPY . /app/
RUN ls /app/
#Build react/vue/angular bundle static files
RUN npm run build
EXPOSE 5000
# serve build folder on port 5000
CMD ["serve", "-s", "build", "-p", "5000"]
fails at step RUN npm run build with the following error:
Step 8/10 : RUN npm run build
---> Running in d4b3bc5de229
> payed-fe#0.1.0 build /app
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/index.js
Cannot find file './app' in './src'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! payed-fe#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the payed-fe#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! /root/.npm/_logs/2018-12-20T15_52_14_979Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
ERROR: Job failed: exit code 1
However on my local machine everything works like a charm (npm start, npm run build, even same Dockerfile on my local builds successfully).
Thanks in Advance!
--- EDIT 1 ---
yes ls gives the same output on my local system and CI.
./src/index.js is just my entry file. Here are the contents:
import React from "react";
import ReactDOM from "react-dom";
import App from "./app";
import * as serviceWorker from "./serviceWorker";
ReactDOM.render(<App />, document.getElementById("root"));
serviceWorker.unregister();
And yes the paths are perfectly alright as it is running successfully on my local machine.
--- EDIT 2 ---
Output of /root/.npm/_logs/*.log after I changed the working dir to /payed - Still no luck!
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm#5.6.0
3 info using node#v8.11.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle payed-fe#0.1.0~prebuild: payed-fe#0.1.0
6 info lifecycle payed-fe#0.1.0~build: payed-fe#0.1.0
7 verbose lifecycle payed-fe#0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle payed-fe#0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/payed/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle payed-fe#0.1.0~build: CWD: /payed
10 silly lifecycle payed-fe#0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle payed-fe#0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle payed-fe#0.1.0~build: Failed to exec build script
13 verbose stack Error: payed-fe#0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
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 emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid payed-fe#0.1.0
15 verbose cwd /payed
16 verbose Linux 4.14.48-coreos-r2
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v8.11.1
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error payed-fe#0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the payed-fe#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 ]
Try CI=false
CI=true is the default...

brunch build --production fails only in production

Out of the blue build script started to fail. No changes in environment or configs at all. Works fine in dev, fails in prod.
Both dev and prod (both Ubuntus):
$ npm -v
5.3.0
$ node -v
v6.11.2
In dev:
oleg#DevVM ~/Code/loaded.bike/assets $ npm run deploy
> # deploy /home/oleg/Code/loaded.bike/assets
> brunch build --production
17:49:59 - info: compiling
17:49:59 - info: compiled 19 files into 2 files, copied 32 in 6.9 sec
In prod:
deploy#loaded-bike-app:~/builds/assets$ npm run deploy
> # deploy /home/deploy/builds/assets
> brunch build --production
00:45:30 - error: Initialization error - Could not load global module 'jquery'. Possible solution: add 'jquery' to package.json and `npm install`. Could not load global module 'jquery'. Possible solution: add 'jquery' to package.json and `npm install`.
Stack trace was suppressed. Run with `LOGGY_STACKS=1` to see the trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # deploy: `brunch build --production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # deploy 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/deploy/.npm/_logs/2017-08-12T00_45_30_084Z-debug.log
Full log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using npm#5.3.0
3 info using node#v6.11.2
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle #~predeploy: #
6 info lifecycle #~deploy: #
7 verbose lifecycle #~deploy: unsafe-perm in lifecycle true
8 verbose lifecycle #~deploy: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/deploy/builds/assets/node_modules/.bin:/home/deploy/bin:/home/deploy/.local
/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle #~deploy: CWD: /home/deploy/builds/assets
10 silly lifecycle #~deploy: Args: [ '-c', 'brunch build --production' ]
11 silly lifecycle #~deploy: Returned: code: 1 signal: null
12 info lifecycle #~deploy: Failed to exec deploy script
13 verbose stack Error: # deploy: `brunch build --production`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at EventEmitter.emit (events.js:191:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:891:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid #
15 verbose cwd /home/deploy/builds/assets
16 verbose Linux 4.8.0-41-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
18 verbose node v6.11.2
19 verbose npm v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error # deploy: `brunch build --production`
22 error Exit status 1
23 error Failed at the # deploy script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Adding jquery, tether to package.json fixes require error but then it just chokes on sass compile. Is this just JS missfiring async function out of order or what is going here? Once again, it started to fail completely out of the blue. Deployed just fine yesterday and today if fails without me changing anything. Any clue what might be wrong here?
EDIT:
package.json:
{
"repository": {},
"license": "MIT",
"scripts": {
"deploy": "brunch build --production",
"watch": "brunch watch --stdin"
},
"dependencies": {
"bootstrap": "^4.0.0-alpha.6",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html"
},
"devDependencies": {
"babel-brunch": "6.0.6",
"brunch": "2.10.10",
"clean-css-brunch": "2.10.0",
"css-brunch": "2.10.0",
"sass-brunch": "2.10.4",
"uglify-js-brunch": "2.1.1"
}
}
I'm actually seeing this crap on prod (but not on dev)
npm ERR! peer dep missing: jquery#>=3.0.0, required by bootstrap#4.0.0-beta
npm ERR! peer dep missing: popper.js#^1.11.0, required by bootstrap#4.0.0-beta
What is that about? Bootstrap defines those as dependencies (not peerDependency) in its own package.json. npm doesn't pull in dependencies now?
"bootstrap": "^4.0.0-alpha.6"
Needed to lock the version. Bootstrap went from alpha.6 to beta yesterday. Messed everything up. No idea why is started to fail only on one machine (even after npm cache clear). Sass compile fails under beta, so I locked it to alpha.6 for now.
I think I need to start locking dependency versions. This took way too long to figure out.

Resources