I am trying to run a pipeline for my Angular App but when it comes to the "npm run build" part it crashes, the fail reason is "Container "Build" exceeded memory limit." I tried messing around with the memory settings in the yml file, for instance adding 'size 2x'and changing the memory amount assigned to docker.
bitbucket-pipelines.yml:
image: node:14.17.0
options:
docker: true
size: 2x
pipelines:
custom:
prod-deployment:
- step:
name: Build angular app
#services:
# - docker
caches:
- node
services:
- docker
size: 2x # Double resources available for this step.
script:
- mv .npmrc_config .npmrc
- npm install --unsafe-perm
- npm install -g #angular/cli#12.2.6
- free -m
- npm run dashboard:build
- wget "censored for security"
artifacts:
- dist/**
- step:
name: Deploy artifacts using SCP to PROD
deployment: production
size: 2x # Double resources available for this step.
script:
- pipe: atlassian/scp-deploy:1.1.0
variables:
USER: $USERNAME
SERVER: $SERVER
REMOTE_PATH: 'Censored for Security'
LOCAL_PATH: 'dist/*'
dev-deployment:
- step:
name: Build angular app
#services:
# - docker
caches:
- node
services:
- docker
size: 2x # Double resources available for this step.
script:
- mv .npmrc_config .npmrc
- npm install --unsafe-perm
- npm install -g #angular/cli#12.2.6
- free -m
- npm run build
- wget 'Censored for Security'
artifacts:
- dist/**
- step:
name: Deploy artifacts using SCP to PROD
deployment: production
size: 2x # Double resources available for this step.
script:
- pipe: atlassian/scp-deploy:1.1.0
variables:
USER: $USERNAME
SERVER: $SERVER
REMOTE_PATH: 'Censored for Security'
LOCAL_PATH: 'dist/*'
definitions:
services:
docker:
memory: 4096
Console error message:
Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! build: `node --max_old_space_size=6144 node_modules/#angular/cli/bin/ng build --configuration=calio && npm run `
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the 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/2021-10-14T08_40_46_012Z-debug.log
Related
I'd like to execute my unit tests using JEST on GITLAB, but it seeem's not working.
It works on my local machine but not on GitLab.
The entire code of .gitlab-ci.yml :
image: node:16
cache:
paths:
- node_modules
install:
stage: build
script: npm ci
jest:
stage: test
script: npm run test:ci
artifacts:
when: always
reports:
junit:
- junit.xml
Package.json
"test": "jest",
"test:ci": "jest --config ./jest.config.js --ci --reporters=default --reporters=jest-junit"
Error :
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-12T08_05_01_634Z-debug-0.log
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
I found the issue by replacing the Node version (same version in my local machine) : image: node:14.
You need to have a step to install, better to check with GitLab CI document
image: node:16
cache:
paths:
- node_modules
install:
stage: build
script: npm ci
jest:
stage: test
script: npm run test:ci
artifacts:
when: always
reports:
junit:
- junit.xml
I tried to create a GitHub action to build my application and it fails to install node module and return error that origin already exist
Please note that is is not a git fatal error that we get when push/pull
Please find my GitHub action code
name: My Desktop Build
on:
push:
branches:
- desktop-build
jobs:
release:
runs-on: macos-10.15
steps:
- name: Check out Git repository
uses: actions/checkout#v2
with:
path: current-repo
- name: Check out 2nd repo
uses: actions/checkout#v2
with:
repository: 5sfayas/private-repo
path: private-repo
ref: 'desktop-build'
ssh-key: ${{secrets.SSH_PRIVATE_KEY}}
- name: Adding SSH KEY
uses: webfactory/ssh-agent#v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Install npm in private-repo - 2nd repo
run: |
cd private-repo
npm i && npm run build
Error
npm ERR! code 3
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects remote add origin ssh://git#github.com/5sfayas/node-deperend-private-repo.git
npm ERR! error: remote origin already exists.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/runner/.npm/_logs/2022-02-03T04_45_01_401Z-debug.log
Error: Process completed with exit code 3.
I found the issue. My package.json is not updated with the latest changes. which is related to Angular update. I checkout to I pull the mast branch and with my branch and work.
configure Cloud Build to build and test Node.js but am getting error.
code snippet of cloudbuild.yml file
steps:
- id: 'APP INSTAL NPM'
name: node:$_NODE_VERSION
entrypoint: npm
args: ['install', '--prefix ./ui']
- id: 'APP BUILD PROCESS WITH NODE NPM'
name: node:$_NODE_VERSION
entrypoint: npm
args: ['run', 'build', '--prefix ./ui']
timeout: 6000s # 20 minute
git reop inside ui directory i have a application so adding --prefix still getting this error
Step #1 - "APP BUILD PROCESS WITH NODE NPM": npm ERR! code ENOENT
Step #1 - "APP BUILD PROCESS WITH NODE NPM": npm ERR! syscall open
Step #1 - "APP BUILD PROCESS WITH NODE NPM": npm ERR! path /workspace/package.json
Step #1 - "APP BUILD PROCESS WITH NODE NPM": npm ERR! errno -2
Step #1 - "APP BUILD PROCESS WITH NODE NPM": npm ERR! enoent ENOENT: no such file or directory, open '/workspace/package.json'
Step #1 - "APP BUILD PROCESS WITH NODE NPM": npm ERR! enoent This is related to npm not being able to find a file.
For those who are encountering this problem, GCP cloud-build has a dir field to set the working directory. This snippet should work:
steps:
- id: 'APP INSTAL NPM'
name: node:$_NODE_VERSION
dir: 'ui'
entrypoint: npm
args: ['install']
- id: 'APP BUILD PROCESS WITH NODE NPM'
name: node:$_NODE_VERSION
dir: 'ui'
entrypoint: npm
args: ['run', 'build']
I tried to create a github action that build my electron app with vue and vue-cli-plugin-electron-builder,but I can't install Dependencies by npm
my folder tree like this:
| .gitignore
| babel.config.js
| LICENSE
| package-lock.json
| package.json
| README.md
| vue.config.js
| yarn.lock
|
+---public
| favicon.ico
| index.html
| test.jpg
|
\---src
| App.vue
| background.js
| main.js
| preload.js
|
+---assets
| ...
|
\---components
...
when I run the CI,I found a error that
npm ci
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm#5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache\_logs\2021-08-01T04_59_20_385Z-debug.log
Error: Process completed with exit code 1.
this is my blank.yml:
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: Build
runs-on: windows-latest
steps:
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node#v1
with:
node-version: 16
- name: Install Dependencies
run: |
npm ci
- name: Electron Build
run: |
npm run electron:build --windows nsis --x64 --ia32
I tried search on bing with the key word "npm install failed in github action" but I found nothing helpful.
also,I tried using 'npm install' instead the 'npm ci', but it showed the same error message that it can't find the package.json
the 'npm install' 's error message like this:
Run npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\a\example\example/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'D:\a\example\example\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache\_logs\2021-08-01T05_12_56_060Z-debug.log
Error: Process completed with exit code 1.
How can I solve it?
English is not my native language; please excuse typing errors.
You are not checking out your code and directly running NPM CI.
Below piece of code should do the job for you
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: Build
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout#v2
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node#v1
with:
node-version: 16
- name: Install Dependencies
run: |
npm ci
- name: Electron Build
run: |
npm run electron:build --windows nsis --x64 --ia32
We created a vuejs library proyect in Gitlab and created a simple pipelines that excecuted after when we pushed the commit.
We have a problem when last job execute the npm version patch (that update the patch in the project) but... it's not updated and it's doesn't work.
.gutlab-ci.yml
image: node:8.10.0-slim
cache:
paths:
- node_modules/
before_script:
- npm install
stages:
- lint
- test
- deploy
test:
stage: test
script:
- npm run peers:add && npm run test:unit
tags:
- docker
lint:
stage: lint
script:
- npm run lint
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
publish:
stage: deploy
script:
- npm run peers:remove
- echo -e "//gitlab.com/api/v4/projects/<my-project>/packages/npm/:_authToken=${CI_NPM_TOKEN}" > ~/.npmrc
- npm login
- npm version patch
- npm publish
And package.json
[...]
"scripts": {
...
"build:dev": "npm run clean && webpack --config build/webpack.config.dev.js",
"version": "npm run build:dev && git add -A dist",
"postversion": "git push --follow-tags"
...
}
[...]
Jobs lint and test working but the publish not.
[...]
removed 4 packages in 9.428s
$ echo -e "//gitlab.com/api/v4/projects/<my-project>/packages/npm/:_authToken=${CI_NPM_TOKEN}" > ~/.npmrc
$ npm login
Username: npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/...-debug.log
ERROR: Job failed: exit code 1
We need when the Merge Request it's accepted, automatically builed library and upload to npm repository with a new version (new patch, npm version patch). It's possible?
Thx.
npm login is an interactive command so doesn't work in CI very well. Try using the package npm-login-noninteractive to pass your credentials via command line. You can install it globally in your before_script:
before_script:
- npm i -g npm-login-noninteractive
Then call it in place of npm login in your publish script.