eslint not found in TravisCI Deploy - node.js

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

Related

npm ERR! when installing firebase tools in gitlab CI/CD

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

Angular dependency errors, during pipeline

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

How do I build react and node together?

I've encountered a slight problem. I know that I can build react-app using npm run build and it will create optimized build folder which I can load to production. But some days ago I started to use node.js with my react application. I am confused now - how should I build such an app now?
My folders structure:
my-app-|
|-client-|
| |-package.json // root react package file
|
|
|- server.js // node.js (express) root file
|- package.json // root node package file
EDIT 1
> server#1.0.0 build C:\Users\Horseman.mini\PhpstormProjects\landing
> npm run build && cd ./client && npm run build
> server#1.0.0 build C:\Users\Horseman.mini\PhpstormProjects\landing
> npm run build && cd ./client && npm run build
> server#1.0.0 build C:\Users\Horseman.mini\PhpstormProjects\landing
> npm run build && cd ./client && npm run build
> server#1.0.0 build C:\Users\Horseman.mini\PhpstormProjects\landing
> npm run build && cd ./client && npm run build
'npm' is not recognized as internal or external command, operable program or batch file
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 build: `npm run build && cd ./client && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#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:\Users\Horseman.mini\AppData\Roaming\npm-cache\_logs\2021-02-22T14_49_23_308Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 build: `npm run build && cd ./client && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#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:\Users\Horseman.mini\AppData\Roaming\npm-cache\_logs\2021-02-22T14_49_23_345Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 build: `npm run build && cd ./client && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
PS npm --version returns 6.14.10
If I go to client folder and build it will build, but without server side
You can now delegate the responsibility of serving your frontend build folder to the server.js i.e the server only. The simplest thing could be using express.static to serve the frontend like so :-
app.use(express.static(path.join(__dirname, "./dist"))); where app is the instance of your express server.
where ./dist is the relative path to your root folder so something like my-app/dist where you place your build files. Again it's totally upto you what name you want to use. Essentially all the static files i.e js,css and html will be part of this dist folder and will be served to the user when he/she hits the base path. Since both frontend and backend would be available from the same server, there would not be any need to handle CORS scenarios as well unless well it's absolutely required by your implementation.
Using parent folder with package.json and put your respective build commands in that.
my-app-|
|-client-|
| |-package.json // root react package file
|
|
|- server.js // node.js (express) root file
|- package.json // root node package file ---> add build command for front and back here.
Your root package.json can have following command.
{
"build": "npm run build && cd ./client && npm run build"
}
This will build your backend first and then frontend, if you want both command to run simultaneously then you can use package like concurrently.

Errors when trying to deploy a react website with firebase

every time I run "npm run deploy:development" I get this:
MacBook-Pro:frontend eug$ npm run deploy:development
> app-frontend#0.1.0 deploy:development /Users/eugenebv/Documents/PetHotel/frontend
> firebase use development && cross-env REACT_APP_ENVIRONMENT=development npm run build && firebase deploy --only hosting,storage
sh: firebase: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! app-frontend#0.1.0 deploy:development: `firebase use development && cross-env REACT_APP_ENVIRONMENT=development npm run build && firebase deploy --only hosting,storage`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the app-frontend#0.1.0 deploy:development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I have firebase and firebase-tools installed, although i see "firebase: command not found".
I ran the alias command to set firebase, whenever I run any firebase command, it works.

After npm run deploy errors occured

After npm run deploy i have errors like above
Repo on Github
I am trying to deploy my react-app on gh-pages on Github (create-react-app)
'gh-pages' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world-4#0.1.0 deploy: `npm run build&&gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world-4#0.1.0 deploy script 'npm run build&&gh-page
s -d build'.
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 hello-world-4 package
,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build&&gh-pages -d build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hello-world-4
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls hello-world-4
npm ERR! There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jan\AppData\Roaming\npm-cache\_logs\2017-05-12T17_55_00_56
9Z-debug.log
So I run this command npm install --save gh-pages
like below
After that I run the command npm run deploy
My code published successfully like below.
For more details just follow this link by Facebook which is given below.
(https://facebook.github.io/create-react-app/docs/deployment#github-pages-https-pagesgithubcom)
I hope your issue will be resolved. In case of error please reply.
please install gh-pages and it ready to go
To install
npm install gh-pages
to deploy
add this to package.json
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
and then this
npm run deploy
gh pages stands for GitHub Pages. It is simply a way to deploy a website via a github repo. Basically, NPM is yelling because when it attempts to run the command deploy, there is not link or reference to the line
$npm run build&&gh-pages -d build
You need make sure that gh-pages -d build is defined. A place to start would be running gh-pages --man or gh-pages --help
I facing the same problem I do the following command before
git push
not working. After
git push
I do the same command it works correctly.
npm install gh-pages
and deploy
npm run deploy

Resources