I am trying to integrate my Ionic app with Angular into Gitlab CI/CD.
When running the jobs, my deploy job fails every time.
The pipeline runs until the command - npm config set unsafe-perm true
without any problems.
Then I want to install the firebase tools with - npm i -g firebase-tools. After that many things happen and a few thousand lines later, there is always this error message.
2305 npm timing command:i Completed in 24044ms
2306 npm ERR! code 12307npm ERR! path /root/.nvm/versions/node/v16.18.0/lib/node_modules/firebase-tools/node_modules/protobufjs
2308 npm ERR! command failed
2309 npm ERR! command sh -c -- node scripts/postinstall
2310 npm ERR! internal/modules/cjs/loader.js:638
2311 npm ERR! throw err;
2312 npm ERR! ^
2313 npm ERR!
2314 npm ERR! Error: Cannot find module '/root/.nvm/versions/node/v16.18.0/lib/node_modules/firebase-tools/node_modules/protobufjs/scripts/postinstall'
2315 npm ERR! at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
2316 npm ERR! at Function.Module._load (internal/modules/cjs/loader.js:562:25)
2317 npm ERR! at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
2318 npm ERR! at startup (internal/bootstrap/node.js:283:19)
2319 npm ERR! at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
2320 npm timing npm Completed in 24194ms
2321 npm ERR! A complete log of this run can be found in:
2322 npm ERR! /root/.npm/_logs/2022-10-27T00_16_16_747Z-debug-0.log
2324 Cleaning up project directory and file based variables00:01
2326 ERROR: Job failed: exit code 1
Before the first jobs start, I use a workaround with nvm to install the Node version I use in the project.
stages:
- build
- deploy
default:
tags:
- nodejs
before_script:
- node --version
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
- export NVM_DIR="$(\[ -z "${XDG_CONFIG_HOME-}" \] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
- \[ -s "$NVM_DIR/nvm.sh" \] && . "$NVM_DIR/nvm.sh"
- nvm ls-remote
- nvm install v16.18.0
- node --version
After that, a job runs that builds the webapp and runs a Lint test.
build-webapp:
stage: build
script:
- cd shareloc #enter the project path
- npm i -silent
- npm i #ionic/cli --silent
- npx ionic build --prod
- npm run lint
# - npm run run-e2e-tests
artifacts:
expire_in: 10 mins
paths:
- shareloc/www/
And finally, when a merge request is pushed to the master, a deploy should be run. We want to host our app on Firebase.
I have already found on the Internet that the command
npm config set unsafe-perm true
should help, however nothing has changed.
deploy-webapp:
stage: deploy
script:
- cd shareloc #enter the project path
- npm config set unsafe-perm true
# - npm install --unsafe-perm -g firebase-tools
- npm i -g firebase-tools
- npx firebase deploy --token $FIREBASE_TOKEN
only:
- master
My technology stack:
Ionic 6.20.3
Node 16.18.0
Firebase
Related
The following chain of events had occured.
The Angular website application was pretty outdated, possibly v3 and was upgraded to 8.2.8, couldnt go all the way due to a dependency on mdbbootstrap which would require a rewrite in many places, made a change and the pipeline and check completed.
Coming back from another project i ran into this problem Angular project produces javascript error "core.js:23018 Uncaught TypeError: Cannot read properties of undefined (reading 'id')", which was solved by npm -ci
Now after making my current changes, and sending off to gitlab pipeline, the following errors occur
npm ERR! While resolving: angular-date-value-accessor#0.0.1
npm ERR! Found: #angular/core#8.2.14
npm ERR! node_modules/#angular/core
npm ERR! #angular/core#"~8.2.8" from the root project
npm ERR! peer #angular/core#"8.2.14" from #angular/animations#8.2.14
npm ERR! node_modules/#angular/animations
npm ERR! #angular/animations#"~8.2.8" from the root project
npm ERR! peer #angular/animations#">=6.0.0 <9.0.0" from angular-calendar#0.26.11
npm ERR! node_modules/angular-calendar
npm ERR! angular-calendar#"^0.26.11" from the root project
npm ERR! 23 more (#angular/common, #angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #angular/core#"^2.0.0" from angular-date-value-accessor#0.0.1
npm ERR! node_modules/angular-date-value-accessor
npm ERR! angular-date-value-accessor#"0.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #angular/core#2.4.10
npm ERR! node_modules/#angular/core
npm ERR! peer #angular/core#"^2.0.0" from angular-date-value-accessor#0.0.1
npm ERR! node_modules/angular-date-value-accessor
npm ERR! angular-date-value-accessor#"0.0.1" from the root project
this is the gitlab-ci yaml
stage: build_staging
image: node:lts
script:
- grep -rli '%COMMIT_HASH%' * | xargs -i# sed -i "s/%COMMIT_HASH%/$CI_COMMIT_SHORT_SHA/g" #
- cd src/Web
- npm install
- npm run buildstaging
artifacts:
paths:
- src/Web/dist/
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
only:
refs:
- develop
Deploy Web Staging:
stage: deploy_staging
image: xueshanf/awscli
script:
- cd src/Web
- aws s3 sync ./dist s3://$STAGING_BUCKET_NAME/ --delete
- echo "Invalidate index.html"
- aws cloudfront create-invalidation --distribution-id $STAGING_DISTRIBUTION_ID --paths /index.html
only:
refs:
- develop
(fyi its the build_staging that is the problem)
I am assuming what was fixed on my local machine is now no longer valid for npm install on npm:lts
What would be the proper course of direction, is it as simple as
npm ci( a very demanding operation) instead of npm install ? or git clean ?
I also noticed, although everything works fine locally
in package.json and lock it has
"#angular/core": "~8.2.8",
but in my node_modules it has 8.2.14 in /#angular/core/
after running npm ci
ok here is what i did to get it working. This would not be a problem if ng commands would work so it could auto resolve dependency problems. Each problem gitlab complained about i manually uninstalled and installed to see the error, and its dependency issue. I upgraded either the component or dependency. until all were gone. Some components had to go completely, but none required a re-code of any usage (i think so far, it hasnt been fully tested).
Now when i finally resolved all these issues, i would get errors such as this
npm ERR! path /builds/0/WebSites/customerportal/CustomerPortal/src/Web/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /builds/0/WebSites/customerportal/CustomerPortal/src/Web/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
allot more all pointing to gyp, and some problem with python version.
I changed the version of the image to Node:14 in the yaml file, and the building stage would complete. Also, the deploy stage would complete, (but the C# api layers time out on warning: 8 tasks failed to start
I am using NVM to install Node.js 16.15.0 inside a Docker container.
I get an error when running npm ci:
npm ERR! command failed
npm ERR! command sh -c node lib/install.js
npm ERR! /atomix/node_modules/npm-conf/lib/conf.js:169
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: EACCES: permission denied, stat '/root/.nvm/versions/node/v16.15.0'
npm ERR! at Object.statSync (fs.js:898:3)
npm ERR! at Conf.loadUser (/atomix/node_modules/npm-conf/lib/conf.js:162:21)
npm ERR! at module.exports (/atomix/node_modules/npm-conf/index.js:32:7)
npm ERR! at Object.<anonymous> (/atomix/node_modules/get-proxy/index.js:2:36)
npm ERR! at Module._compile (internal/modules/cjs/loader.js:936:30)
npm ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
npm ERR! at Module.load (internal/modules/cjs/loader.js:790:32)
npm ERR! at Function.Module._load (internal/modules/cjs/loader.js:703:12)
npm ERR! at Module.require (internal/modules/cjs/loader.js:830:19)
npm ERR! at require (internal/modules/cjs/helpers.js:68:18) {
npm ERR! errno: -13,
npm ERR! syscall: 'stat',
npm ERR! code: 'EACCES',
npm ERR! path: '/root/.nvm/versions/node/v16.15.0'
npm ERR! }
My Dockerfile:
FROM trzeci/emscripten
EXPOSE 8080/tcp
RUN apt update \
&& apt install libglew-dev -y \
&& wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash \
&& apt install htop \
&& apt install procps -y
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 16.15.0
RUN chmod +x $HOME/.nvm/nvm.sh
RUN . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
WORKDIR /atomix
RUN npm i flow-typed -g
# NPM 7+ automatically installs peer deps so disable this as it fails our install
RUN npm config set legacy-peer-deps true
These installation instructions for NVM are copied from NVM itself.
When I roll it back from 16.15.0 to 10.16.0 (which I know works) it works successfully. Why does the newer version of Node.js fail?
I would suggest using one of the official Node.JS Docker images for whatever part you need Node for. You can use a build arg to specify the version.
Use a multi-stage build to create whatever assets you need for the Node stage.
ARG NODE_VERSION=16.5
# Build stage
FROM emscripten/emsdk AS emcc
WORKDIR /build
COPY your-src-files/ ./
RUN emcc ...
# Run
FROM node:${NODE_VERSION}
WORKDIR /atomix
RUN npm config set legacy-peer-deps true
RUN npm i flow-typed -g
COPY --from=emcc /build/your-compiled-files ./
RUN ...
To change the Node version, you simply build the image with a NODE_VERSION build arg...
docker build --build-arg NODE_VERSION=17 .
lam getting the error below while running npm run dev
[webpack-cli] TypeError: this.program.configureOutput is not a function
at new WebpackCLI (/home/vagrant/sites/ecom/node_modules/webpack-cli/lib/webpack-cli.js:19:22)
at runCLI (/home/vagrant/sites/ecom/node_modules/webpack-cli/lib/bootstrap.js:7:21)
at Object. (/home/vagrant/sites/ecom/node_modules/webpack-cli/bin/cli.js:23:5)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at runCli (/home/vagrant/sites/ecom/node_modules/webpack/bin/webpack.js:54:2)
npm ERR! code 2
npm ERR! path /home/vagrant/sites/ecom
npm ERR! command failed
npm ERR! command sh -c mix
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2021-03-19T11_14_07_947Z-debug.log
npm ERR! code 2
npm ERR! path /home/vagrant/sites/ecom
npm ERR! command failed
npm ERR! command sh -c npm run development
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2021-03-19T11_14_07_974Z-debug.log
First, try to update your node.js file and then run "npm run dev" and if you again faced the same problem follow the following steps:
Step1: composer update
Step2: rm -rf node_modules
Step3: npm cache clear --force
Step4: npm install
Step5: npm outdated
In this step, it will update your laravel-mix version, it is in the package.json.
Step6: npm install
Step7: npm run dev
After all these steps, everything is good.
I hope it solve your problem.
I came across this problem when trying to build and run webpack (and webpack-cli locally), after check out from Github (not at all related to Laravel).
I found that I forgot to run yarn install for webpack-cli which lead to the issue that an existing version of commander#6 was used, but webpack-cli requires commander#7.
npm list commander should tell you that the webpack-cli dependency is unsatisfied. yarn install should fix it.
I am trying to get a site to deploy to Firebase using TravisCI. I keep running into an issue when the functions deploy and try to run lint. eslint doesn't seem to be there, even though I added a command to cd and npm install. I'm sure this is some kind of no-brainer. What am I missing?
Here's my .travis.yml:
language: node_js
node_js:
- 12
deploy:
provider: firebase
project: "*****"
message: "Deployed from Github by TravisCI"
token:
secure:
*******
env:
global:
secure:
*****
branches:
only:
- master
before_deploy:
- npm install -g gatsby-cli
- rm -rf node_modules/*/.git/
- npm install
- gatsby build
- cd functions && npm install --dev && cd ..
Here's the error in the Travis log:
Installing deploy dependencies
dpl.2
Preparing deploy
dpl.3
Deploying application
=== Deploying to 'covid19-reports'...
i deploying storage, firestore, functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint /home/travis/build/amygroshek/covid19reports/functions
> eslint .
sh: 1: eslint: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! functions# lint: `eslint .`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the functions# lint 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! /home/travis/.npm/_logs/2020-03-23T00_34_17_951Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
I wanted to follow this page to run JSBin locally.
I just installed xcode 8.2 in my mac. Now, npm -v returns 3.10.9; node -v returns v7.2.1. npm install returns
/Users/softtimur/Startup/WebProjects/jsbin$ npm install
> jsbin#3.40.2 postinstall /Users/softtimur/Startup/WebProjects/jsbin
> grunt build && npm run selenium:install
Running "concat:dist" (concat) task
File "public/js/prod/jsbin-3.40.2.js" created.
Running "concat:runner" (concat) task
File "public/js/prod/runner-3.40.2.js" created.
Running "uglify:dist" (uglify) task
File "public/js/prod/jsbin-3.40.2.min.js" created.
Running "uglify:runner" (uglify) task
File "public/js/prod/runner-3.40.2.min.js" created.
Running "uglify:embed" (uglify) task
File "public/js/embed.min.js" created.
Running "uglify:addons" (uglify) task
File "public/js/prod/addon-tern-3.40.2.min.js" created.
Done, without errors.
> jsbin#3.40.2 selenium:install /Users/softtimur/Startup/WebProjects/jsbin
> selenium-standalone install
----------
selenium-standalone installation starting
----------
---
selenium install:
from: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
to: /Users/softtimur/Startup/WebProjects/jsbin/node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip
to: /Users/softtimur/Startup/WebProjects/jsbin/node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver
---
firefox install:
from: https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-macos.tar.gz
to: /Users/softtimur/Startup/WebProjects/jsbin/node_modules/selenium-standalone/.selenium/geckodriver/0.11.1-x64-geckodriver
---
File from https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip has already been downloaded
---
File from https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar has already been downloaded
---
File from https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-macos.tar.gz has already been downloaded
-----
selenium-standalone installation finished
-----
> jsbin#3.40.2 prepublish /Users/softtimur/Startup/WebProjects/jsbin
> npm run snyk-protect
> jsbin#3.40.2 snyk-protect /Users/softtimur/Startup/WebProjects/jsbin
> snyk protect
Successfully applied Snyk patches
It seems that jsbin has been installed, however, I could not find it under /usr/local/lib/node_modules/npm/node_modules/.
Does anyone know where it is?
Edit 1: npm start returns:
/Users/softtimur/Startup/WebProjects/jsbin$ npm start
> jsbin#3.40.2 start /Users/softtimur/Startup/WebProjects/jsbin
> (sleep 2 && open http://localhost:3000) & ./bin/jsbin
Config from /Users/softtimur/Startup/WebProjects/jsbin/lib/config.local.json
module.js:472
throw err;
^
Error: Cannot find module '/Users/softtimur/Startup/WebProjects/jsbin/node_modules/sqlite3/lib/binding/node-v51-darwin-x64/node_sqlite3.node'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/softtimur/Startup/WebProjects/jsbin/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.2.1
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! jsbin#3.40.2 start: `(sleep 2 && open http://localhost:3000) & ./bin/jsbin`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsbin#3.40.2 start script '(sleep 2 && open http://localhost:3000) & ./bin/jsbin'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jsbin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! (sleep 2 && open http://localhost:3000) & ./bin/jsbin
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs jsbin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls jsbin
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/softtimur/Startup/WebProjects/jsbin/npm-debug.log
Additionally, I think .bin/jsbin it runs is what has been inside the git folder; it was not built by my npm install.
I could not find it under /usr/local/lib/node_modules/npm/node_modules/
That is to be expected, because you copied the package repo to ~/Startup/WebProjects/jsbin, for use in development, as opposed to using npm install -g jsbin to install it globally, for regular use.
Using npm start from ~/Startup/WebProjects/jsbin, as Benjamin suggests, is the right approach.
npm start does find the jsbin executable, namely in subfolder ./bin (if you look in package.json, key "scripts", you'll see line
"start": "(sleep 2 && open http://localhost:3000) & ./bin/jsbin").
The error message you're getting is actually generated by jsbin itself, indicating a problem with the package's installation.