0

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.

Mohammad.Kaab
  • 1,025
  • 7
  • 20

1 Answers1

0

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

ThatsME
  • 147
  • 7
  • Thanks for our answer, But this code is located in the minified file in the dist folder. This is not something I've wrote. It's been generated by the vue-cli itself. – Mohammad.Kaab Apr 23 '22 at 09:36
  • were you able to rectify the issue? usually, VUE_APP* variables are defined in `.env` files. and then builders replace those in the final build. do you know from where these variables are coming? I am pretty sure this is config side issue not build or vue issue – ThatsME Apr 23 '22 at 09:54
  • Yes, they are environment variables, ```VUE_APP_API_URL=http://localhost:85/ VUE_APP_URL=http://localhost:8080/``` They are located inside the .env file. – Mohammad.Kaab Apr 23 '22 at 10:07