Error while building react app on gitlab-ci - reactjs

I am trying to deploy a react app using GitLab-ci when I build on local it works fine but when building on the pipeline I get the error just before the build complete:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! spinspace-admin#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spinspace-admin#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/2020-05-20T18_07_19_210Z-debug.log
Running after_script
00:01
Uploading artifacts for failed job
00:02
ERROR: Job failed: exit code 1
This is the before_script in my GitLab-ci.yaml
before_script:
- apt-get update
- npm install
- npm run build
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
please I need help...

Related

github action npm run build not working, but works locally

Our team created a react web app and want to use github action to push the project to Kuberntes. Here is the Dockerfile:
### STAGE 1: Build ###
FROM node:14.5.0 as build
RUN mkdir -p /src/app
WORKDIR /src/app
# Install app dependencies
COPY package.json /src/app/
RUN npm install && \
npm install -g pushstate-server
# Bundle app source
COPY . /src/app
# Build and optimize react app
RUN npm run build:staging
### STAGE 2: Production Environment ###
FROM nginx:1.19.2
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /src/app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
when I run docker locally with command
docker build --tag abc:test .
It built the image successfully. But when I push it github action, it will stop at RUN npm run build:staging. And the Error message is
/src/app/src/Components/SideBar/SideBarLinks/index.tsx
TypeScript error in /src/app/src/Components/SideBar/SideBarLinks/index.tsx(124,9):
Property 'children' is missing in type '*** onEntered: () => void; ***' but required in type 'CollapseProps'. TS2741
122 | dropdownWrapperProps=*** 'data-tour': 'support-wrapper' ***
123 | dropdownToggleProps=*** 'data-tour': 'support-dropdown-button' ***
> 124 | collapseProps=***
| ^
125 | onEntered: () => ***
126 | const sidebarItemsWrapper = document.querySelector(
127 | '.side-bar-items-wrapper'
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/2020-09-21T06_19_14_044Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dashboard_redo#4.0.0 api:staging: `cross-env REACT_APP_API_BASE_URL=https://staging.jetsonai.com/api/v3 npm run integrations-url:staging "npm" "run" "build"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dashboard_redo#4.0.0 api:staging 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/2020-09-21T06_19_14_076Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dashboard_redo#4.0.0 build:staging: `cross-env REACT_APP_MODE=test npm run api:staging npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dashboard_redo#4.0.0 build:staging 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/2020-09-21T06_19_14_093Z-debug.log
The command '/bin/sh -c npm run build:staging' returned a non-zero code: 1
##[error]Process completed with exit code 1.
Any idea?

How can I disable npm run build errors?

I currently have an interesting error with npm run build and I don't know what's wrong. Is there a way to run the build with errors?
$ npm run build
> todoo#0.1.0 build D:\FitnessTracker
> tslint -p tslint.json && ./node_modules/.bin/tsc
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todoo#0.1.0 build: `tslint -p tslint.json && ./node_modules/.bin/tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todoo#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! C:\Users\raul.gimcojocaru\AppData\Roaming\npm-cache\_logs\2020-02-11T13_25_39_104Z-debug.log```
That project seems to expect an UNIX-style shell and you're on Windows.
You could try replacing the build script entry with just
"build": "tsc"
but there's no guarantees things will still work.

laravel react command run dev not working

C:\wamp64\www\want>npm run dev
> # dev C:\wamp64\www\want
> npm run development
> # development C:\wamp64\www\want
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
The system cannot find the path specified.
events.js:167
throw er; // Unhandled 'error' event
^
Error: spawn node_modules\webpack\bin\webpack.js ENOENT
at notFoundError (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Emitted 'error' event at:
at ChildProcess.cp.emit (C:\Users\coolm\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development 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\coolm\AppData\Roaming\npm-cache\_logs\2018-09-18T16_07_49_646Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev 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\coolm\AppData\Roaming\npm-cache\_logs\2018-09-18T16_07_49_686Z-debug.log
C:\wamp64\www\want>
I'm trying to hook up my Laravel application with React. I followed the step of running the command "php artisan preset react" but after I was instructed to run npm install & run dev. I keep getting the following error. Does anyone have a similar problem?
Try doing full reset:
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

Deploy AngularJS app into docker container

I am trying to deploy my angularjs app into a docker container:
myapp/web/Dockerfile
FROM node:latest
RUN mkdir /myapp
ADD . /myapp
WORKDIR /myapp
RUN npm install -g phantomjs-prebuilt
RUN npm install -g grunt-cli
RUN npm install -g grunt
RUN npm install -g bower
RUN npm install
RUN bower install --allow-root
RUN npm run v2
EXPOSE 9000
CMD ["grunt", "serve"]
myapp/docker-compose.yml
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
web:
build: ./web
image: myapp/web
environment:
- VIRTUAL_HOST=myapp.dev
Outputs
> phantomjs-prebuilt#2.1.14 install /usr/local/lib/node_modules/phantomjs-prebuilt
> node install.js
Considering PhantomJS found at /usr/local/bin/phantomjs
Looks like an `npm install -g`
Could not link global install, skipping...
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...
Received 22866K total.
Extracting tar contents (via spawned process)
Removing /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1497270232242/phantomjs-2.1.1-linux-x86_64 -> /usr/ local/lib/node_modules/phantomjs-prebuilt/lib/phantom
Phantom installation failed { Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-149727 0232242/phantomjs-2.1.1-linux-x86_64' -> '/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom'
errno: -13,
code: 'EACCES',
syscall: 'link',
path: '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1497270232242/phantomjs-2.1.1-linux-x86_64',
dest: '/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom' } Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs- 2.1.1-linux-x86_64.tar.bz2-extract-1497270232242/phantomjs-2.1.1-linux-x86_64' -> '/usr/local/lib/node_modules/phantomjs-prebuilt/lib/ph antom'
npm info lifecycle phantomjs-prebuilt#2.1.14~install: Failed to exec install script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt#2.1.14 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt#2.1.14 install 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/2017-06-12T12_23_56_471Z-debug.log
I tried to add USER root before the global npm install but nothing changes.
Any help apreciated
I have the same issue, and this works for me.
sudo npm install -g phantomjs#2.1.1 --unsafe-perm
https://github.com/Medium/phantomjs/issues/707#issuecomment-320989493

error on npm start command in angular js

I am completely new to angular js and I have started learning through this tutorial. While running the development web server using npm start I get the below error :
> angular-phonecat#0.0.0 prestart /path_to/angular-phonecat
> npm install
> angular-phonecat#0.0.0 postinstall /path_to/angular-phonecat
> bower install
> angular-phonecat#0.0.0 start /path_to/angular-phonecat
> http-server -a 0.0.0.0 -p 8000
events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:8000
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at Server._listen2 (net.js:1238:14)
at listen (net.js:1274:10)
at net.js:1383:9
at doNTCallback3 (node.js:452:9)
at process._tickCallback (node.js:358:17)
at Function.Module.runMain (module.js:469:11)
at startup (node.js:136:18)
at node.js:963:3
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v4.2.4
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! angular-phonecat#0.0.0 start: `http-server -a 0.0.0.0 -p 8000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-phonecat#0.0.0 start script 'http-server -a 0.0.0.0 -p 8000'.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! http-server -a 0.0.0.0 -p 8000
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /pathto/angular-phonecat/npm-debug.log
I have also tried changing the address and port but still the same error.
Can someone help?
PS : I am using Osx.
go to the command line and do
ps aux | grep 8000
and get PID number, should be the second column i believe, like a 5 digit number, ,then;
kill -9 <PID>
try npm start again.
I advice learning angular2 instead. As it wont be of much benefit for you learning angular 1 now.
EADDRINUSE -- this means the port which this server is trying to use is already in use by some other process so first kill it and then run your server again.

Resources