title: Extract version and name from Package.json using Jenkinsfile (Jenkins Pipeline)
body: <p>My question is simple I want to extract version and name from package.json, but when I extract version and name I got more URL see attached file.Why is that?</p>
  
  <p>Jenkinsfile</p>
  
  <pre><code> pipeline {
      agent any
      environment { 
          CI = 'true'
          //IMAGE = bat 'node -e "console.log(require(`./package.json`).name);"'
          //VERSION = bat(script: 'npm run get-version')
          //VERSION = bat '(npm run version --silent)'
          //PACKAGE_VERSION = bat '(node -p -e "require(\'./package.json\').version")'
          GIT_COMMIT_SHORT_HASH = GIT_COMMIT.take(7)
          REPOSITORY = 'repo.dimiroma.com'
          PORT = '8085'
          LATEST = 'latest'
  
      }
       stages {
          stage('Set Build Variables') {
              steps {
                  script {
  
                      VERSION = bat(script: '''node -e "console.log(require('./package.json').version)"''', returnStdout: true).trim()
  
                      def getProjectName = { -&gt;
                          return bat(
                              returnStdout: true,
                              script: 'node -e "console.log(require(\'./package.json\').name);"'
                          ).trim()
                      }
  
                      //VERSION = getProjectVersion()
                      IMAGE = getProjectName()
                   }
              }
          }
          stage('Information') {
                steps {                  
                    script{
                        bat 'node -v'
                        bat 'git --version'
                        bat 'docker -v'                     
                        echo "JOB BASE NAME: ${JOB_BASE_NAME} BUILD-NUMBER: ${BUILD_NUMBER}"
                        echo "Version: ${VERSION}"
                        //echo "Version: ${PACKAGE_VERSION}"
                        echo "Name: ${IMAGE}"
                        echo "Branch_name: ${env.BRANCH_NAME}"
  
                        final scmVars = checkout(scm)
                        echo "scmVars: ${scmVars}"
                        echo "scmVars.GIT_COMMIT: ${scmVars.GIT_COMMIT}"
                        echo "scmVars.GIT_BRANCH: ${scmVars.GIT_BRANCH}"
                    }             
                }
          }
          stage('Install Dependencies') {
              steps {
                  bat 'npm install'
              }
          }
          stage('Test') {
              steps {
                  bat 'npm test -- --coverage a'
              }
          }
          stage('Create Docker Image'){
                steps {
                    bat "docker images"             
                    bat "docker build . -t ${IMAGE}:${VERSION}-${GIT_COMMIT_SHORT_HASH}"          
                }
            }
      }
  }
  </code></pre>
  
  <p>Dockerfile</p>
  
  <p>Please Help.</p>