Building Vue app after upgrading to version 5 starts throw "Uncaught SyntaxError: Unexpected token ':'"

289 Views Asked by At

After upgrading @vue/cli-service to version ^5.0.4. the build command is not functioning normally as before. after building vue js for production, this was showing Uncaught SyntaxError: Unexpected token ':' in the console. After checking the code, The error was coming from

const Ee = () => `http://localhost:85/${Se()}`, Se = () => Ce() && we() ? 'api' : 'v1/api',
        Ce = () => 'DEVELOPMENT' === {
          NODE_ENV: 'production',
          VUE_APP_API_URL: 'http://localhost:85/',
          VUE_APP_URL: 'http://localhost:8080/',
          BASE_URL: '/'
        }?.VUE_APP_ENVIRONMENT, we = () => {
          NODE_ENV:'production', VUE_APP_API_URL
        :
          'http://localhost:85/', VUE_APP_URL
        :
          'http://localhost:8080/', BASE_URL
        :
          '/'
        }

I appreciate any help.

1

There are 1 best solutions below

3
On

After Better Indentation and pasting code in visual studio code. I found this

enter image description here

Notice the red squiggly line on lines no. 17, 18, and 19. This is happening because javascript is expecting a function body and you are returning an object.

const we = () => ({ VUE_APP_API_URL: 'http://localhost:85/' })

Note: the round bracket before the curly bracket. () => ({ ... }) instead of () => { ... }

Hope this helps