Can't resolve '#splinetool/runtime' when try to deploy on GitHub pages - node.js

hi geeks I am trying to deploy my website through Github pages
so I saw this video that shows me how to deploy the Nextjs website to Github pages.
https://www.youtube.com/watch?v=dalXCXCIPHM
but the build was failed with this error
Failed to compile.
./node_modules/#splinetool/react-spline/dist/react-spline.es.js
Module not found: Can't resolve '#splinetool/runtime' in '/home/runner/work/abdallahzaher2022/abdallahzaher2022/node_modules/#splinetool/react-spline/dist'
Import trace for requested module:
./node_modules/#splinetool/react-spline/dist/react-spline.es.js
./components/WelcomeComp.tsx
> Build failed because of webpack errors
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abdallahzaher#0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the abdallahzaher#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! /home/runner/.npm/_logs/2022-11-24T15_13_56_537Z-debug.log
Error: Process completed with exit code 1.
so I found that problem is with the spline 3d model
I hope there is a solution because the npm run build runs successfully
this is some of my changes that i think it is related
next.config.js
/** #type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
loader: "akamai",
path: " ",
},
};
module.exports = nextConfig;
package.json
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"export": "next export"
},
and finally this is the workflow file in nodejs config in github pages
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run export
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action#v4
with:
folder: out # The folder the action should deploy.

Not sure if you've already solved it, but here we go:
So, to debug this, the following information would be required:
Is it deploying correctly on Vercel?
The image 'akamai' loader is usually not required if you deploy on Vercel since they optimize much stuff behind the scenes.
A complete package.json
Suggestion: Use the default Next.js workflow configuration provided by GitHub Pages and see if the error vanishes.
Finally, here's one of my Next.js websites where I've used Spline extensively.
Feel free to use components/SplineObj.js as a template.

Related

Github Actions with Jest Suddenly Stopped

I registered test-coverage ci in github actions
name: TEST-COVERAGE
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout source code
uses: actions/checkout#v3
- name: Set up Nest.js
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
- name: Set up Node_modules
run: |
cd ./client
rm -rf node_modules
yarn install --immutable --immutable-cache --check-cache
cd ..
cd ./server/gateway
rm -rf node_modules
npm ci
cd ../services/core
rm -rf node_modules
npm ci
cd ../auth
rm -rf node_modules
npm ci
cd ../ticket
rm -rf node_modules
npm ci
- name: Run Test Coverage
run: |
rm -rf node_modules
npm ci
npm run coveralls
- name: Coveralls
uses: coverallsapp/github-action#master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
I passed all the test cases with jest, and while executing it, a situation occurred where the Github action suddenly stopped. Even locally, the test code passes and does not emit an error message, but it stops without any output, so it cannot be solved.
Error: Process completed with exit code 1.
Below is my Current Directory
client
server
gateway
auth
core
ticket
At first, it seemed to be a Github action memory leak, so when I changed the npm install command to npm ci, it ran fine. However, as we added and expanded new features, npm ci encountered the same problem.
https://github.com/boostcampwm-2022/web03-FanUP/actions/runs/3521371482/jobs/5903147717
This is github actions result
"scripts": {
"test": "jest --detectOpenHandles --forceExit",
"coverage": "jest --detectOpenHandles --coverage --forceExit",
"coveralls": "jest --coverage --detectOpenHandles --forceExit && coveralls < ./coverage/lcov.info"
},

Github Actions - Run server & frontend, then execute tests

I would like to use Github Actions for CI and run tests before the branch can be merged.
I have a single repository that has both my server and frontend within it (Nest & Angular). I am using Cypress/Jest for my tests.
I need my backend server running for my frontend cypress tests to pass.
Currently GH Actions doesn't move onto the next step because the backend process is running - but that's what I need to happen...
How should I set this up so that I can use GH Actions for CI?
name: test
on: [push]
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OTHER_SECRETS: ${{ secrets.otherSecrets }}
jobs:
cypress-run:
runs-on: macos-11
steps:
# start cypress w/github action: https://github.com/cypress-io/github-action
- name: Setup Node.js environment
uses: actions/setup-node#v2.5.0
with:
node-version: '16.13.0'
- name: Checkout
uses: 'actions/checkout#v2'
- name: "Start Backend"
run: |
cd server &&
npm install &&
npm run build &&
npm run start:prod
- name: "Start Frontend"
run: |
npm install &&
npm run build &&
npm run start
- name: Cypress run
uses: cypress-io/github-action#v2
with:
record: true
browser: chrome
- name: "Run Jest Tests"
run: |
cd server &&
npm run test
#note: I have tried appending the "&& sleep 10 && curl http://localhost:port -i" option to the npm commands - and it hasn't worked for me.
#note2: It's my first time w/ GH Actions, so maybe I'm missing something obvious!!
#note: I have tried appending the "&& sleep 10 && curl http://localhost:port -i" option to the npm commands - and it hasn't worked for me.
There is a slight error here, && will wait for the previous command to complete and only run the next one if it is successful & would run the previous command in the background and then will move on to running the next one. Therefore as nothing stops your server, && won't work.
I am not sure it is the cleanest way but the following should work, I have used an equivalent to run a UI in one of my projects.
- name: "Start Backend"
run: |
cd server &&
npm install &&
npm run build &&
npm run start:prod &
sleep 5 &&
curl http://localhost:port -I
- name: "Start Frontend"
run: |
npm install &&
npm run build &&
npm run start &
sleep 5 &&
curl http://localhost:port -I
I had the same problem, server running but never moving to the next step of running the Cypress tests.
Thanks didwefixit, using just one & worked to start the server and then run Cypress test script worked:
jobs:
build:
env:
CI: true
strategy:
matrix:
node-version: [14.x, 16.x]
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout#v2
- name: Use Node.js version ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install --prefix client
- run: npm install --prefix server
- run: npm install
- run: npm run build --prefix client
- run: npm run start --prefix server & npm run test
script in client package.json:
"build": "BUILD_PATH=../server/public react-scripts build"
script in server package.json:
"start": "node src/server.js"
script in root package.json:
"test": "npx cypress run"

Nuxt Fatal Error starting nuxt in GitHub Actions

I'm running a GitHub actions workflow that builds and runs a nuxt app for cypress.js testing. I'm receiving a Nuxt Fatal error that I can't seem to figure out from reading the stack when building the app.
FYI, I have looked through EVERY error logged in StackOverflow with this Fatal error but can't seem to find a solution.
Here's my GitHub Actions workflow (everything seems to run OK):
name: Cypress run on push
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [14.17.0]
containers: [1, 2, 3, 4, 5]
steps:
- name: Setup Node
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node }}
- run: node -v
- name: Checkout
uses: actions/checkout#v2
- name: Running npm ci (installing dependencies)
run: npm ci
- name: Running npm install
run: npm install
# Update Browserlist
- run: npx browserslist#latest --update-db
- name: Starting test server and running Cypress
uses: cypress-io/github-action#v2
with:
build: npm run build
start: npm run start
wait-on: 'http://localhost:3000/'
wait-on-timeout: 120
record: true
parallel: true
# browser: chrome
# headless: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
And here is the error. I do not understand why there is an error referring to an unresolved path. The path is actually correct. This also runs locally, in a dev server, staging server, and production without any problem:
[fatal] Nuxt build error
ERROR in ./components/ui/dialogs/SocialMediaWrapper.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./components/ui/dialogs/SocialMediaWrapper.vue?vue&type=script&lang=js&)
Module not found: Error: Can't resolve '#/components/svg/DottedNoteBook' in 'components/ui/dialogs'
# ./components/ui/dialogs/SocialMediaWrapper.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./components/ui/dialogs/SocialMediaWrapper.vue?vue&type=script&lang=js&) 200:0-61 203:20-34
# ./components/ui/dialogs/SocialMediaWrapper.vue?vue&type=script&lang=js&
# ./components/ui/dialogs/SocialMediaWrapper.vue
# ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/trial-view/_id.vue?vue&type=script&lang=js&
# ./pages/trial-view/_id.vue?vue&type=script&lang=js&
# ./pages/trial-view/_id.vue
# ./.nuxt/router.js
# ./.nuxt/index.js
# ./.nuxt/client.js
# multi ./.nuxt/client.js
╭─────────────────────────────╮
│ │
│ ✖ Nuxt Fatal Error │
│ │
│ Error: Nuxt build error │
│ │
╰─────────────────────────────╯
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! JurorSearch#2.18.6 build: `nuxt build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the JurorSearch#2.18.6 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! /home/runner/.npm/_logs/2021-08-17T05_30_28_916Z-debug.log
Error: Process completed with exit code 1.
Figured it out.
The component was calling "DottedNoteBook" but the file name is "DottedNotebook.vue". (Different case for the letter "B".)
I'm not sure why that case issue never came up before or preventing compiling outside of the GitHub Actions, but that was the issue. Thanks, #Tarkan for making me look closer at that.

Firebase deploy works in the console but not in bitbucket pipeline

I'm trying to deploy my webapp to firebase hosting through a bitbucket pipeline, It's not deploying correctly in the pipeline but in the console it works no problem. This is what I do in the console:
npm run build
firebase login:ci
firebase deploy --project $PROJECT_NAME
In the pipeline I'm running this YAML script:
image: node:10.15.3
pipelines:
default:
- step:
name: Install and Build App
caches:
- node
script:
- npm install
- CI=false npm run build
artifacts:
- build/
- step:
name: Deploy App to Firebase
deployment: production
script:
- pipe: atlassian/firebase-deploy:0.6.0
variables:
KEY_FILE: $KEY_FILE
PROJECT_ID: $PROJECT_ID
I think it might have to do with the .firebaserc but I'm not sure. this is the .firebaserc:
firebase target:apply hosting $PROJECT_ID $DOMAIN
Maybe someone can shed some light on why this isn't working, I'm new to pipeline scripts and I don't really see the issue, it succeeds in deploying to firebase hosting but It's not working at all on the actual domain.
When you run the command firebase login:ci that should generate a TOKEN, you add that token in Bitbucket in your Repository Settings > Repository Variables. What ever name you choose should match your pipeline. In my example I use FIREBASE_TOKEN_CI. When I commit my changes to bitbucket, it runs the pipeline, builds and deploys.
You can always modify your script in your package.json so in your cli you can run npm run build:prod like you would run npm run start, etc and use the build:prod in the yml.
here is an example:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build:prod": "ng build --prod=true"
}
CODE BELOW is a pipeline.yml I use for Ionic/Angular
NOTE: Artifacts is the folder your build files are generated after running build. Angular is called dist, so you might use dist/. My example uses www/** that is Ionics build output. You have some CI=False in your example, I have not seen that nor use that and my project builds and deploys. My second script is for cloud functions
- cd functions
- npm install
- cd ..
you can omit that part if you don't have functions. I have recently had a error about OAuth and I had to generate a new token with login:ci and replace my token, and it was working again for deploy. Hope this helps anyone. I had problems at first also and found a working format that I can adapt to other frameworks.
image: node:10.15.3
pipelines:
default:
- step:
name: Install, Build
caches:
- node
deployment: test
script:
- npm install
- npm run build:prod
artifacts:
- www/**
- step:
name: Deploy to Firebase
deployment: production
script:
- cd functions
- npm install
- cd ..
- pipe: atlassian/firebase-deploy:0.3.4
variables:
FIREBASE_TOKEN: '$FIREBASE_TOKEN_CI'

.ebextensions with CodePipeline and Elastic Beanstalk

I started working on my first CodePipeline with node.js app which is hosted on github. I would like to create simple pipe as follow:
Github repo triggers pipe
Test env (Elastic Beanstalk app) is built from S3 .zip file
Test env runs npm test and npm lint
If everything is OK then QA env (another EB app) is built
For above pipe I've created .config files under .ebextensions directory:
I would like to use npm install --production for QA and PROD env, but it seems that EC2 can't find node nor npm. I checked logs and EC2 triggered npm install by default in temporary folder, then it fails on my first script and app catalogue is always empty.
container_commands:
install-dev:
command: "npm install"
test: "[ \"$NODE_ENV\" = \"TEST\" ]"
ignoreErrors: false
install-prod:
command: "npm install --production"
test: "[ \"$NODE_ENV\" != \"TEST\" ]"
ignoreErrors: false
Is it posible to run unit tests and linting without jenkins?
container_commands:
lint:
command: "npm run lint"
test: "[ \"$NODE_ENV\" = \"TEST\" ]"
ignoreErrors: false
test:
command: "npm run test"
test: "[ \"$NODE_ENV\" = \"TEST\" ]"
ignoreErrors: false
I set NODE_ENV for each Elastic Beanstalk instance. No matter what I will do every time my pipe fails because of npm is not recognized, but how is it possible if I'm running 64bit Amazon Linux with node.js ? What's more I cannot find any examples about CodePipeline with node.js in AWS Docs. Thanks in advance!
If you're using AWS for CI/CD, you can use CodeBuild. However, Github provides a great feature called Actions for running Unit Tests, which I find much simpler than AWS. Anyway, I will walk you through both examples:
Using AWS for running Unit Tests
Essentially, you could create a new stage into your CodePipeline, and configure the CodeBuild for running Unit Tests, e.g.
First, add a buildspec.yml file in the root folder of your app so you can use the following example:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
commands:
- echo Installing Mocha globally...
- npm install -g mocha
pre_build:
commands:
- echo Installing dependencies...
- npm install
- npm install unit.js
build:
commands:
- echo Build started on `date`
- echo Run Unit Tests and so on
- npm run test
- npm run lint
post_build:
commands:
- echo Build completed on `date`
# THIS IS OPTIONAL
artifacts:
files:
- app.js
- package.json
- src/app/*
- node_modules/**/*
You can find everything you need in the BackSpace Academy, this course is for free:
AWS DevOps CI/CD - CodePipeline, Elastic Beanstalk and Mocha
Using Github for running Unit Tests
You could create your custom actions using Github, it will automatically set up everything you need in your root folder, e.g.
After choosing the appropriate workflow, it will automatically generate a folder/file ".github > workflow > nodejs.yml".
So it will look like this:
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
steps:
- uses: actions/checkout#v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm test
env:
CI: true
I hope you could find everything you need in this answer. Cheers
Have you incorporated CodeBuild into your pipeline?
You should
1) Create a pipeline whose source is your github account. Go through the setup procedure so that commits on a particular branch trigger the Codepipeline
2) Create a test stage in your Codepipeline which leverages the CodeBuild service. In order to run your Node tests, you might need to provide a configured build environment. And you probably also need to provide a build spec file that specifies the tests to run etc.
3) Assuming that the test stage passes, you can determine if the pipeline continues to another stage which is linked to an elasticbeanstalk app environment which supports the Node platform. These environments are purely for artifacts that have passed testing, so I see no need to have the .ebextensions commands written above.
Have a read of what CodeBuild can do to help you run tests for Node,
https://aws.amazon.com/codebuild/
Good luck!

Resources