I am using cmd as administrator to install java using npm install java and i am getting an error. All environment variables are set as well. Any help will be very applicable. Thanks in advance..
gyp ERR! configure error
gyp ERR! stack Error:gypfailed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\MyName\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js
:336:16)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\MyName\\AppData\\Roaming\\npm\\node_modules\\node-gy
p\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\WINDOWS\system32
gyp ERR! node -v v8.1.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Follow this procedure
rm -rf ~/.node-gyp/
rm -r node_modules/.bin/;
rm -r build/
npm install bcrypt
and set
npm config set msvs_version 2013 --global
Related
I'm getting the below errors when installing java in a node folder. I've got Python 3.10.9 and JDK installed on my Mac OSX. Any tips on what I need to do?
atianwei#a07817af543e _utils % npm install -g java
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/java
npm ERR! command failed
npm ERR! command sh /var/folders/93/dh0k18fx7kx_3cgmg_s0l0jm0000gr/T/install-ef324c76.sh
npm ERR! CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp#9.0.0
npm ERR! gyp info using node#16.17.1 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.9 found at "/opt/homebrew/opt/python#3.10/bin/python3.10"
npm ERR! gyp info spawn /opt/homebrew/opt/python#3.10/bin/python3.10
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/java/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/atianwei/Library/Caches/node-gyp/16.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/atianwei/Library/Caches/node-gyp/16.17.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/atianwei/Library/Caches/node-gyp/16.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/java',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/java.cpp:1:
npm ERR! ../src/java.h:7:10: fatal error: 'jni.h' file not found
npm ERR! #include <jni.h>
npm ERR! ^~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/nodejavabridge_bindings/src/java.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/java
npm ERR! gyp ERR! node -v v16.17.1
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
installed python and jdk, thought it would resolve the issue from this article: https://www.geeksforgeeks.org/how-to-run-java-code-in-node-js/
I have problem while reading from settings.xml while docker image creation
Docker file
# syntax=docker/dockerfile:1
FROM eclipse-temurin:17-jre-jammy
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
COPY mvnw settings.xml ./
RUN ./mvnw -s settings.xml dependency: resolve
COPY src ./src
CMD ["./mvnw", "spring-boot:run"]
I tried this docker file also
# syntax=docker/dockerfile:1
FROM eclipse-temurin:17-jre-jammy
COPY .mvn/ .mvn
COPY mvnw ./
COPY pom.xml ./
COPY settings.xml ./
RUN ./mvnw -s settings.xml dependency: resolve
COPY src ./src
CMD ["./mvnw", "spring-boot:run"]
and getting this error:
Could not find goal '' in plugin org.apache.maven.plugins:maven-dependency-plugin:3.3.0 among available goals analyze, analyze-dep-mgt, analyze-duplicate, analyze-only, analyze-report, build-classpath, collect, copy, copy-dependencies, display-ancestors, get, go-offline, help, list, list-classes, list-repositories, properties, purge-local-r
epository, resolve, resolve-plugins, sources, tree, unpack, unpack-dependencies -> [Help 1]
#14 64.62 [ERROR]
#14 64.62 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
#14 64.62 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
#14 64.62 [ERROR]
#14 64.62 [ERROR] For more information about the errors and possible solutions, please read the following articles:
#14 64.62 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
COPY mvnw .
COPY pom.xml .
# assume settings.xml is in current directory
COPY settings.xml .
RUN mvnw -s settings.xml dependency:resolve
COPY src ./src
CMD ["mvnw", "spring-boot:run"]
Context: I'm able to dockerize and run my Springboot app locally just fine with the below, following the most common recommendations of using a generated jar file to run the app via Docker.
Question: Since it's bad practice to push the jar file to the repo as it's going to potentially contain secrets from the local application.yml files, and the docker file depends on the jar file, how can I have my app be dockerized not just locally but on the cloud in anywhich cicd pipeline? Would my next step be modifying the dockerfile to copy over the project directory, and handle generating the jar file itself? Or should I not be using a jar at all and copying over the directory and using a CMD [Some Spring Run command)]
DockerFile:
FROM maven:3.8.5-openjdk-17
ADD target/xyz.jar xyz.jar
ENV RESTFUL_PORT 8080
ENV PORT_POSTGRES 5432
EXPOSE $RESTFUL_PORT
EXPOSE $PORT_POSTGRES
ENTRYPOINT ["java", "-jar","/xyz.jar"]
The pom.xml plugin which generates the jar file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
Docker Steps
Build the Jar:
mvn clean install
Build the Image:
docker build -t xyz -f Dockerfile
Run the Image:
docker run -d -p 8080:8080 -e "SPRING_PROFILES_ACTIVE=dev" xyz
The Dockerfile can be like this:
# Build Stage
FROM maven:3.8-openjdk-17-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package
# Execution Stage
FROM openjdk:17-oracle
COPY --from=build /home/app/target/demo-0.1-SNAPSHOT.jar /usr/local/lib/demo.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/usr/local/lib/demo.jar"]
To build docker image
$ docker build -t demo-app:1.0 .
Run docker image
$ docker run -p 8080:8080 demo-app:1.0
Simple build part of pom.xml will work
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
FROM maven:3.8-openjdk-17-slim AS build
WORKDIR /workspace/app
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src
RUN mvn -f /workspace/app/pom.xml install
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
FROM openjdk:17-oracle
VOLUME /tmp
ARG DEPENDENCY=/workspace/app/target/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.demo.DemoServiceApplication"]
Got it working with this, only needing to change the last line.
Docker Command:
docker build -t demo -f Dockerfile .
docker run -d -p 8080:8080 -e "SPRING_PROFILES_ACTIVE=develop" demo:latest
This results in a DockerFile that is not dependent on an external jar file and can be run in isolation against a repo for a cicd pipeline.
Source: Toptal - Multi-Stage Build
I have a maven project which is building fine on local but failing on gitlab ci/cd pipeline.
The error which is coming as follows:
25869 [INFO] ------------------------------------------------------------------------
925869 [INFO] BUILD FAILURE
925870 [INFO] ------------------------------------------------------------------------
925870 [INFO] Total time: 15:24 min
925871 [INFO] Finished at: 2021-06-08T10:38:11Z
925871 [INFO] ------------------------------------------------------------------------
925891 [ERROR] Failed to execute goal org.apache.cxf:cxf-java2ws-plugin:3.3.0:java2ws (generate-rec-data-service-wsdl) on project descapreusables-server: Error while executing process.
925898 [ERROR] Try to run this goal using <fork>true</fork> and <classpathAsEnvVar>true</classpathAsEnvVar>.
925905 [ERROR] Command line was: /usr/java/openjdk-11/bin/java --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED -DexitOnFinish=true -cp /builds/arcesium/internal/fiatech/.m2/repository/org/apache/cxf/cxf-java2ws-plugin/3.3.0/cxf-java2ws-plugin-3.3.0.jar:/builds/arcesium/internal/fiatech/.m2/repository/com/sun/xml/ws/jaxws-ri/2.3.0/jaxws-ri-2.3.0.pom:/builds/arcesium/internal/fia
The final error is coming as **: Cannot run program "/bin/sh" (in directory "/builds/arcesium/internal/fiatech/performa/descap/DESCap-Reusables/src/modules/server/target"): error=7, Argument list too long**
The command which its building is very huge but on local its not happening.
The gitlab ciYaml file is as :
variables:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
#MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
#MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
#MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# This template uses jdk8 for verifying and deploying images
image: maven:3.3.9-jdk-8
stages:
- build
#- test
build:
image: "674283286888.dkr.ecr.us-east-1.amazonaws.com/core-infra/openjdk-maven:3.8.1-openjdk11"
stage: build
tags:
- identity-mnrltdev
#before_script:
# - yum -y install maven
# - mvn -version
script:
- pwd
- ls -ltr
- mvn clean package -DfailIfNoTests=false -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true -s settings.xml
#- mvn clean install -DskipTests=true
I have a Jenkins maven job and I'm getting the following error when I run the job.
Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/My First Maven Job
No credentials specified
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://github.com/yankils/hello-world.git # timeout=10
Fetching upstream changes from https://github.com/yankils/hello-world.git
> /usr/bin/git --version # timeout=10
> /usr/bin/git fetch --tags --force --progress -- https://github.com/yankils/hello-world.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision de043c505e7adab1f892498ca231280298fc2674 (refs/remotes/origin/master)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f de043c505e7adab1f892498ca231280298fc2674 # timeout=10
Commit message: "Update Dockerfile"
> /usr/bin/git rev-list --no-walk de043c505e7adab1f892498ca231280298fc2674 # timeout=10
Parsing POMs
Established TCP socket on 34699
[My First Maven Job] $ " /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin/java" -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/opt/maven/apache-maven-3.6.3/boot/plexus-classworlds-2.6.0.jar:/opt/maven/apache-maven-3.6.3/conf/logging jenkins.maven3.agent.Maven35Main /opt/maven/apache-maven-3.6.3 /var/cache/jenkins/war/WEB-INF/lib/remoting-4.2.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 34699
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program " /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin/java" (in directory "/var/lib/jenkins/workspace/My First Maven Job"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:804)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1856)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 12 more
Finished: FAILURE
I can see it was looking at /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin where as I have openjdk /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64/jre
How can I fix this on Jenkins server?
Set JAVA_HOME to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64
as opposed to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64